Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Understanding Steering Behaviors: Seek
using UnityEngine;
public class Seek : MonoBehaviour
{
private Transform pointer;
public float speed = 1.0f;
public float mass = 1.0f;
private Vector2 curVelocity;
private void Start()
{
pointer = FindObjectOfType<Pointer>().transform;
curVelocity = Vector2.zero;
}
private void Update()
{
Vector2 desiredVelocity = (pointer.position - transform.position).normalized * speed;
Vector2 steering = desiredVelocity - curVelocity;
steering = steering / mass;
curVelocity += steering;
transform.Translate(curVelocity * Time.deltaTime );
}
}
@HonorsoftEntertainment

This comment has been minimized.

Copy link

@HonorsoftEntertainment HonorsoftEntertainment commented Feb 23, 2020

the script is misnamed or you have a type-o in the class name.
SteeringSeek.cs should have the class named "SteeringSeek" not "Seek"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment