2d simple ai and spawning
How do I make an ai that goes from the x axis from 1-10 or something. I already can do the collisions as I have made "spike" scripts and "fall" scripts. I just want to figure out how to make the AI spawn at a certain rate, kinda like the goomba monsters that spawn out of the pipes in Mario (:D), and have it move on the x-axis from 1-10. Also, is there a way that when it collides with a vertical object called "ground", it jumps, and continues moving, so that my AI don't get stuck?
Answer by g__l · Jan 12, 2016 at 09:19 PM
Use instantiate to create the object (from prefab) in a function use invokeRepeating to call that function repeatedly and vector3.movetowards to move to a point and back. That's the logic of it and what functions to use, hope it helps.
Links to documentation
http://docs.unity3d.com/ScriptReference/Object.Instantiate.html
http://docs.unity3d.com/ScriptReference/MonoBehaviour.InvokeRepeating.html
http://docs.unity3d.com/ScriptReference/Vector3.MoveTowards.html
Your answer
Follow this Question
Related Questions
How i make the AI follow player by tag 1 Answer
Checking collision before instantiating prefab 0 Answers
Enemy 2D check for collision 1 Answer
AI spawns in face-down... 2 Answers