TheKingsRace/Assets/Scripts/KingScripts/Bumper.cs

28 lines
1018 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bumper : MonoBehaviour {
public float bumpPower = 30;
// Is called whenever something collides with the bumper
void OnTriggerEnter(Collider objectHit) {
if (objectHit.gameObject.tag == "ArcherTarget") {//Checks if the other object is the player
Debug.Log("Bump");
MoveStateManager playerMovement = objectHit.GetComponent<MoveStateManager>();
float DirBumpX = playerMovement.driftVel.x * -1;//Inverts the Player Velocity x
float DirBumpY = .1f;
float DirBumpZ = playerMovement.driftVel.z * -1;//Inverts the Player Velocity z
Vector3 DirBump = new Vector3(DirBumpX, DirBumpY, DirBumpZ);//Creates a direction to launch the player
DirBump = Vector3.Normalize(DirBump);//Normalizes the vector to be used as a bump direction
playerMovement.GetHit(DirBump, bumpPower);
//
}
}
}