mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-04-03 23:55:33 -05:00
28 lines
1018 B
C#
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);
|
|
//
|
|
}
|
|
}
|
|
}
|