Hi, I just have a quick question. I’m just finishing up the logic of a flying enemy that I have in my game and I need to know how would I tell the object to move towards and through the point I specified. That’s pretty much it. I’ve used Vector2.MoveTowards, and tried setting the rigidbody’s velocity to the point and it wouldn’t say that it was a huge success… Because I want the enemy to have a ramming attack, I just think that I’m going about it slightly incorrectly…
Anyways here is my code (that pertains to my question):
private void LockOn()
{
targetPoint = new Vector2(target.transform.position.x, target.transform.position.y);
lockedOn = true;
}
if (lockedOn)
{
box.isTrigger = true;
rb.velocity = Vector2.MoveTowards(transform.position, targetPoint, speed / 25 * Time.deltaTime);
}
else if (!lockedOn)
{
LockOn();
}
Thanks in advance for any help!