Hi guys,
could anyone help me out here?
When my character touches a spring object, he flies up into the air as expected, but when he comes back down again, he falls through the spring and does nothing, i then have to get my character to walk outside the object then back in again to activate it. what am i doing wrong?
using UnityEngine;
using System.Collections;
public class Spring : MonoBehaviour {
public GameObject player;
private Rigidbody RbPlayer;
public int springAmount;
//private bool springHit = false;
// Use this for initialization
void Start () {
RbPlayer = player.GetComponent();
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Spring")
{
// springHit = true;
RbPlayer.AddForce (new Vector3 (0, springAmount,0));
}
}
}
↧