- Home /
Just need some ai info.
I would like an AI with two different axis. One on the X axis. One on the Y axis. I would like the AI to look at the player separately on both axis. Also I only want it to work within a certain radius. And the last thing, I know how to apply gravity but how would I do this without ignoring colliders.
transform.position.y -= gravityValue * Time.deltaTime;
So what's the question? You state a couple of desires and intentions, but not a clearly defined question. What do you have, what isn't working, what specific problem within your implementation are you trying to overcome?
Answer by Loius · Jun 19, 2012 at 06:40 PM
Flatten your calculations to the plane around each axis (set .x or .y of a copy of the target position to zero) and if (playerposition - myposition).magnitude > radius don't do anything at all.
To apply gravity without ignoring colliders use rigidbodies with Use Gravity checked.
Edit: You can directly set rigidbody velocities so they'll go however fast you want but also respect collisions.
thanks this is going to narrow down my research but what if I want to use a character controller
Use the scripting reference. Character Controller has a $$anonymous$$ove function than handles collisions automatically.