I made a Jump Pad script with the express purpose of being an all around script for thrusting the player in different directions. Here’s the script:
using UnityEngine;
using System.Collections;
public class Thrust_Pad : MonoBehaviour
{
public int thrustX;
public int thrustY;
public int thrustZ;
void OnTriggerEnter(Collider col)
{
if (col.gameObject.name == "Ghost" && col.GetComponent<Rigidbody>())
{
Vector3 padThrust = new Vector3 (thrustX, thrustY, thrustZ);
col.GetComponent<Rigidbody>().AddForce (padThrust * 100, ForceMode.Impulse);
}
}
}
Bearing in mind that the player’s name is Ghost, I’m not sure why it’s not working. I verified the trigger works with a simple print code and even that it’s detecting a rigidbody with “Print (col.GetComponent());” and it gives me “Ghost (UnityEngine.Rigidbody)” so I’m not sure what’s making it not thrust at all. I set all 3 integers to 10 in the inspector for testing purposes and the multiplied 100 in the script was to exaggerate it as much as possible so get it to do anything.