TheKingsRace/Assets/Scripts/KingScripts/Bumper.cs
Melbyj1125 ba1b2706a6 fixed kick sort of, fixed bumper and boulder
Fix for kick works but is kind of strange and I want to adjust it later
in the future
2022-02-02 18:38:16 -06:00

28 lines
1014 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");
PlayerMovement playerMovement = objectHit.GetComponent<PlayerMovement>();
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);
//
}
}
}