Fish.FixedUpdate C# (CSharp) Method

FixedUpdate() public method

public FixedUpdate ( ) : void
return void
    void FixedUpdate()
    {
        // apply a physics force in the direction of our destination
        rigidbody.AddForce( ( destination - transform.position ).normalized * Time.fixedDeltaTime * speed, ForceMode.VelocityChange );

        // if fish is near our current destination, then set a new destination
        if ( Vector3.Distance( transform.position, destination ) < stoppingDistance ) {
            SetNewDestination();
        }
    }