Question by
martn00 · Dec 22, 2016 at 05:48 PM ·
vector3velocityjumpingplayer movementboxcollider
Change the "jumping speed" in the FirstPersonController by using another script
Hello Evrybody. I am trying to make a script for turn on the jumping of the FPSController. What I want to happen is that when I walk in a Boxcollider (the trigger), that it change the jumping speed of the script of the FPSController. The script that write has been blocked by the "FirstPersonController". So I think I need to send a new value to the "FirstPersonController", but how? (My English is bad)...
using UnityEngine; using System.Collections;
public class ChangeJumpingOfPlayer : MonoBehaviour { private bool inCollider = false; public Rigidbody Rb;
void Start()
{
Rb = GameObject.Find("Player").GetComponent<Rigidbody>();
}
void OnTriggerEnter(Collider o)
{
if (o.tag == "Player")
{
inCollider = true;
}
}
void OnTriggerExit (Collider o)
{
if (o.tag == "Player")
{
inCollider = false;
}
}
// Update is called once per frame
void Update()
{
if (inCollider == true &&Input.GetKeyDown(KeyCode.Space))
{
Rb.velocity = new Vector3(0, 5, 0);
}
}
}
Comment