hey guys
im learning in class on how to get characters to ‘see’
lecturer mentioned 2 ways.
raycasting and using ‘feelers’ which are just colliders with detects if its collided with something.
for the collider method, ive set a character with a box collider in front of it and a constant force added to the character. the collider is set to istrigger and has this script attached to it.
using UnityEngine;
using System.Collections;
public class Feeler_GD : MonoBehaviour
{
public GameObject player;
public float turnSpeed;
void OnTriggerEnter(Collider other)
{
player.rigidbody.AddTorque(0, turnSpeed, 0);
}
void onTriggerExit(Collider other)
{
player.rigidbody.AddTorque(0, -turnSpeed, 0);
}
}
this code results in it kind of just rotating when it gets to an open space…