Hi
I am trying to make my Player Jumps when He hits a mushroom on the top;
The Player has Character Controller and the Mushroom has rigidboy.
I tried most of the solution i found at: http://answers.unity3d.com/search?q=bouncy
Nothing worked.
// some scripts I tried:
var bounceForce : float = 10;
function OnCollisionEnter(hit : Collision)
{
if (hit.gameObject.tag == "Player")
{
Debug.Log("I was called");
hit.rigidbody.AddForce(bounceForce * transform.up, ForceMode.VelocityChange);
}
}
solution two:
function OnCollisionEnter(hit : Collision){
//hit.rigidbody.velocity.y = -hit.rigidbody.velocity.y * 0.8;
if(hit.gameObject.tag=="Player"){
hit.transform.position += Vector3.up * Time.deltaTime;
Debug.Log("hit");
}
}
the above were tried on the Mushroom.
I tried this on the Player: but he acts weird : ignores direction and even falls in the ground sometime
function OnControllerColliderHit(hit: ControllerColliderHit) {
if(hit.gameObject.tag=="mashroom"){
//PlayAudioClip2(ouchsound, transform.position, 1);
//rigidbody.AddForce (Vector3.up * 10);
//transform.Rotate(0,0,90);
Debug.Log("hitting water");
transform.position= Vector3(transform.position.x+1,transform.position.y+2,transform.position.z);
}
}
Any advice will be appreciated
Thanks