- Home /
A few questions about spawning and changing sprites! (2D)
Hello, so I am making a simple puzzle game, and need some help.
How can I spawn X number of objects in a certain area. And make them move in random directions (And define how many objects to spawn and their speed in the inspector)
How to spawn an object with Y sprite and after random amount of seconds change the sprite to X and after few seconds back to Y (So I want to set in the inspector: What is the starting sprite, what is the changed sprite, after how many seconds does the sprite X goes back to
When the level starts I want to know what (red dot: "Y") will be changed to (blue: "X") and if the player clicks the correct one it does something and if player clicks a dot that didn't change the colors do something else.
If I wasn't clear enough you can ask here or on skype: nikkjan
Thanks :D
These are all very basic questions. If you know how to declare variables, you already have 80% of your questions answered. Basically, you are asking others to do everything for you, which is not the purpose of the Unity Answers system. Do a couple of 2D tutorials, then try things out and if you have specific questions, create a thread here and write what you have tried so far, post your script, what the problem is, and what you want to improve.
Some pointers: To generate a random position inside a rectangle, you need Vector2 values for the $$anonymous$$ and max positions. Then you can use Random.Range to find xy values.
Spawning objects can be done via the Instantiate method. To make a timer, declare a float variable and add Time.deltaTime to it every frame in Update().
Hope that helps.
Your answer
Follow this Question
Related Questions
Sprite flip movement script not working! HELP! 0 Answers
2D Sprite leaves a trail when moving diagonally 1 Answer
How to make sprites in SideScroller move in smooth curves 0 Answers
Sprite is not shown moving 1 Answer
Moving 2D sprite along a path 0 Answers