- Home /
Mario Mushroom Bouncy
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
Have you tried changing the physics material from the mushroom to bouncy? =p
I did make the mushroom bouncy.. every time the player hits it the mushroom tries to bounce not the player
thanks
Answer by doomprodigy · Feb 27, 2011 at 11:19 PM
Since those methods are not working for you. Maybe use an empty gameobject above the mushroom with a trigger and when you enter that trigger sendmessage to call the jump function and subtract health from the mushroom. That way you can jump higher and subtract health, inside this function you could also make the mushroom smaller.
I can write this in code when I get home if needed // At School currently
Your answer
Follow this Question
Related Questions
Bouncing back 1 Answer
Bouncing objects and Energy loss 2 Answers
Bounce with speed 1 Answer
perfect bounce when a bullet hits a wall 1 Answer
I wanna setup something like Kinematic option on sphere but with collision checker. 0 Answers