- Home /
Really simple AI that works with physics?
So I´m looking for a simple/basic AI that deals with physics, No need to avoid obstacles. So far i have came up with this but the only problem is that its a Drag-Force so it will fly if the target is at a higher position and when the "hunter" is moving towards the target and i move the target to the side it will just fly past.
var target : Transform;
var speed = 10;
function Update() {
transform.LookAt(target);
target.rigidbody.AddForce(transform.forward * speed);
}
I´m looking for a simple/basic AI that deals with physics
That isnt a question. That's a statement that could mean many things. What specifically do you want to do. $$anonymous$$ake an object fly into the air if the hunter gets close?
I want a object to move toward another object without clipping walls and always be grounded
Answer by AlucardJay · Feb 23, 2013 at 01:49 PM
try this :
var target : Transform;
var speed : float = 10;
var desiredVelocity : Vector3 = Vector3.zero;
var currY : float = 0;
function Update()
{
transform.LookAt(target);
currY = rigidbody.velocity.y;
desiredVelocity = transform.forward * speed;
desiredVelocity.y = currY;
}
function FixedUpdate()
{
rigidbody.velocity = desiredVelocity;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613093203im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
zombie enemy AI 1 Answer
Need help with javascript AI 1 Answer
Zombie AI tutorial 2 Answers
Zombie A.I path finding help 2 Answers
Help with Basic AI 1 Answer