Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Unity make a homing object

// This code was originally written by Brackeys

Vector2 direction = (Vector2)Target.position - rb.position;
direction.Normalize();
float RotateAmount = Vector3.Cross(direction, transform.up).z;
rb.angularVelocity = -RotateSpeed * RotateAmount;
rb.velocity = transform.up * Speed;
 
PREVIOUS NEXT
Tagged: #Unity #homing #object
ADD COMMENT
Topic
Name
8+5 =