I’m trying to make a fireball curve towards a player but it appears to not be working.
The fireball is off the ground, ignoring gravity and does not have constraints.
It has a mass of 1, drag and angular drag are 0.
HomingStrength is set to 1000.
UpdateHoming_Dumb() is called in FixedUpdate().
void UpdateHoming_Dumb()
{
Rigidbody rigidBody = GetComponent<Rigidbody>();
if (Vector3.Dot(rigidBody.velocity, homingTarget.position - transform.position) >= 0)//if target is in front of spell
{
if (Vector3.Dot(Vector3.Cross(rigidBody.velocity.normalized, Vector3.up), homingTarget.position - transform.position) >= 0)//if target is to the left of spell
{
Debug.Log("LEFT" + rigidBody.velocity);
rigidBody.AddRelativeTorque(Vector3.up * -homingStrength);
}
else//if target is to the right of spell
{
Debug.Log("RIGHT" + rigidBody.velocity);
rigidBody.AddRelativeTorque(Vector3.up * homingStrength);
}
}
else//if target is behind spell (over shot)
{
//Debug.Log("BACK");
}
}