I have read the Lerpz documentation on creating the jump pad however i want to do this in my FPS game.
Here is my script
//----jumppad.js----
var jumpAngle:Vector3;
var jumpMagnitude:float=1.0;
function OnControllerColliderHit (entity)
{
//Make sure the triggering entity has a rigidbody before we try to access it!
if(entity.gameObject.tag == "player")
{
print("hit the grav pad");
//Apply the force
entity.rigidbody.AddForce(jumpAngle*jumpMagnitude);
}
}
This script needs a rigid body, which the fps controller doesnt have.
The lerpz script references the third person controller but im not sure how to adapt that to the FPS.
This is what I used for a jumppad in my game, it’s pretty easy
Create a cube gameObject and add this script to it. Make sure the box collider Is Trigger is checked. If you want to play a sound when a player uses the jumppad be sure to add an audiosource to the jumppad too.
JS:
#pragma strict
var strength : int = 10; // Strenght, how high will the jumppad make the player jump
var jumppadsound : AudioClip; // Sound played when a player uses the jump pad
// make sure to check the Is Trigger checkbox in the Box/mesh/whatever collider
function OnTriggerEnter(col : Collider){
// Make sure the "Player" tag is set on the player
if(col.CompareTag("Player")){
col.gameObject.GetComponent(CharacterMotor).SetVelocity(Vector3.up * strength);
audio.PlayOneShot(jumppadsound);
}
}
@script RequireComponent(AudioSource);
Without sound:
#pragma strict
var strength : int = 10; // Strenght, how high will the jumppad make the player jump
// make sure to check the Is Trigger checkbox in the Box/mesh/whatever collider
function OnTriggerEnter(col : Collider){
// Make sure the "Player" tag is set on the player
if(col.CompareTag("Player")){
col.gameObject.GetComponent(CharacterMotor).SetVelocity(Vector3.up * strength);
}
}