Move Homing Mislle (3D)
Hi! I am working with homing missles in 3D space with Freeze position Y and Freeze rotation X (so it's basically 2D space with 3D perspective and 3D models)
According to my idea, missles: 1. Move with inertia (rigidbody) 2. Have maneuvers (instead of methods like transform.LookAt), so player or AI could dodge or trick this missle. Homing missle must use some time to face target
In result I've got missle, that moves to target, but aims strange... twitches, rotates backward. What did I do wrong?
Problem is: missle finds target, but corrects its own direction very strange Variable _engine is transform of the
private IEnumerator MoveAdv (Transform targ)
{
while (Fuel > 0)
{
FuelConsumption();
if (Vector3.Angle (transform.forward, targ.position) > AngleDev)
{
TurnSpeedOn();
Vector3 turn = (transform.position - targ.position).normalized;
_rigid.AddForceAtPosition(-turn * _turnSpeed, _enginePos.position, ForceMode.Acceleration);
}
else
{
TurnSpeedOff();
}
_rigid.AddForceAtPosition(Vector3.forward * _speed, _enginePos.position, ForceMode.Force);
yield return null;
}
yield return null;
}
Your answer
Follow this Question
Related Questions
Smooth Rotation on WASD keys pressed? 1 Answer
Drive Boat from start point to end point and vice versa 1 Answer
Rotate Rigidbody on Y Axis based on Velocity on X and Z axis 3 Answers
Make rigidbody rotate smoothly back to original position if flipped? 1 Answer
Freeze rotation of just the box collider component 0 Answers