I know it’s way easier with a rigidbody but I’m trying to figure out how to implement collision with a character controller.
I have a spinning object to test this out that spins on a loop and if the player object collides with it, they are pushed back. I know that transform.position doesn’t work because it’s instantly placing you in a specific spot.
public float pushBackSpeed = 2.0f;
private void OnTriggerEnter(Collider other)
{
if (other.gameObject == Player)
{
Player.transform.position += transform.position +
transform.forward * -1 * pushBackSpeed;
}
}
//Player.transform.position += Vector3.forward * 10.0f;
//Player.transform.position += new Vector3(0f, 0f, 5.8f);
//Player.transform.position += transform.forward * pushBackSpeed * Time.deltaTime;
I used some more code that wasn’t transform.position but I got rid of it. I tried using another Vector3 with basic adjusted movement code but my player just teleports to the position, rather than moving there at whatever speed I set. I tried to add and adjust controller.Move() code but the same thing happens.
Currently I’m not trying to do anything fancy, I’m just trying to get the player to move back and then improve on it from there.