game-engine

How to create game-wide object in Unity3d without singleton?

偶尔善良 提交于 2021-02-10 14:16:25
问题 Is there a way in Unity3d framework to register an object that would be accessible to all entities in all scenes in the game without resorting to singleton pattern (like a game state object)? 回答1: You could take the following approach: In the scene where the GameObject is created, in a MonoBehavior script attached to the GameObject: Name the GameObject with "name = ..." in Awake() (or in the Editor) Example: myObject.name = "FindMeInEveryScene"; Ref: https://docs.unity3d.com/ScriptReference

Not able to get TextMeshPro text to variable slot in Unity

本小妞迷上赌 提交于 2021-02-05 12:19:14
问题 using TMPro; public TextMeshPro _livesText; public TextMeshPro _scoreText; I am unable to drag the text from the Hierarchy to the variable slot in Inspector. Why is it happening. Please help. 回答1: You seem to speak about a TextMeshProUGUI which in the Inspector is called TextMeshPro - Text(UI) . Note that TextMeshPro != TextMeshProUGUI! There is no inheritance between those two. (Similar to Unity build in TextMesh and UI.Text ) If you want one general field for both types then you need to use

Component based game engine design [closed]

久未见 提交于 2021-01-29 22:30:07
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. I have been looking at game engine design (specifically focused on 2d game engines, but also applicable to 3d

Gamemaker Studio 2: My character won’t transition through rooms

旧街凉风 提交于 2021-01-29 08:30:53
问题 I use transition code that I learned through a Udemy course, but the character in my game will only transition through the first door, and no others. I am using the same object but changing the creation code of the object. I use variables room_ , start_ . I use these to select different rooms and start positions within the creation code. Click the link to view video game - (https://drive.google.com/open?id=1jCWIM3hYymgspW54EPbnUDrNQVZbY_4B). 回答1: I fiddled with the project a bit, I understand

How to prevent automatic newlines, when the output is wider than the console?

心不动则不痛 提交于 2021-01-27 13:12:05
问题 I'm implementing the game of life, using console output. So far it's looking good: However, when I make the width of the output larger than the with of the console, this happens: Instead of letting the lines run offscreen, it inserts a newline. Is there a way to turn this off? I'm on a small laptop, so changing the console width doesn't really help. 回答1: I think you have to get and set the maximum length of the screen. So you get the length. If you need more space you can set the windows size

Gaffer on games timestep: std::chrono implementation

前提是你 提交于 2020-12-01 07:43:09
问题 If you're not familiar with the Gaffer on Games article "Fix your Timestep", you can find it here: https://gafferongames.com/post/fix_your_timestep/ I'm building a game engine, and in an effort to get more comfortable with std::chrono I've been trying to implement a fixed time step using std::chrono for.. a couple of days now and I can't seem to wrap my head around it. Here is the pseudo-code I'm working towards: double t = 0.0; double dt = 0.01; double currentTime = hires_time_in_seconds();

Spliting component in Entity-Component-System demands too much refactoring

ε祈祈猫儿з 提交于 2020-07-08 05:56:17
问题 I have an existing working C++ game library that use Entity-Component-System (ECS). User of my library would like to create some components e.g. Cat :- class Cat{ public: int hp; float flyPower; }; He can modify hp of every cat by e.g. :- for(SmartComponentPtr<Cat> cat : getAll<Cat>()){ cat->hp-=5; //#1 } Some days later, he want to split Cat to HP and Flyable :- class HP{ public: int hp; }; class Flyable{ public: float flyPower; }; Thus, every cat that access hp will compile error (e.g. at

Spliting component in Entity-Component-System demands too much refactoring

老子叫甜甜 提交于 2020-07-08 05:55:11
问题 I have an existing working C++ game library that use Entity-Component-System (ECS). User of my library would like to create some components e.g. Cat :- class Cat{ public: int hp; float flyPower; }; He can modify hp of every cat by e.g. :- for(SmartComponentPtr<Cat> cat : getAll<Cat>()){ cat->hp-=5; //#1 } Some days later, he want to split Cat to HP and Flyable :- class HP{ public: int hp; }; class Flyable{ public: float flyPower; }; Thus, every cat that access hp will compile error (e.g. at

Spliting component in Entity-Component-System demands too much refactoring

◇◆丶佛笑我妖孽 提交于 2020-07-08 05:53:10
问题 I have an existing working C++ game library that use Entity-Component-System (ECS). User of my library would like to create some components e.g. Cat :- class Cat{ public: int hp; float flyPower; }; He can modify hp of every cat by e.g. :- for(SmartComponentPtr<Cat> cat : getAll<Cat>()){ cat->hp-=5; //#1 } Some days later, he want to split Cat to HP and Flyable :- class HP{ public: int hp; }; class Flyable{ public: float flyPower; }; Thus, every cat that access hp will compile error (e.g. at

Unity3D - Build Failed because of “[Unity] ERROR: An asset is marked with HideFlags.DontSave but is included in the build:”

倖福魔咒の 提交于 2020-05-15 05:55:32
问题 Using Unity Cloud Build Service , i my build failed because of "[Unity] ERROR: An asset is marked with HideFlags.DontSave but is included in the build:" error. What I've done so far: 1) i have tried to delete Project Setting and reopen Unity but build is still failed... 2) Change all "Arial" font to custom font on prefab and on all scene, but still failed... Below are compact log of Unity Build Service: 1207: [Unity] WARNING: Shader Unsupported: 'Hidden/BlitToDepth' - Pass '' has no vertex