Explosion problem

Hello,

I have a mine in my game. If the marble rolls over it, then it should create an explosion force, which sends the marble to the opposite direction where it came from. However, the explosion send the marble directly up every time.

How should I fix it?

Here is the script:

var radius 	= 5.0;
var power 	= 250.0;

var explosionPos	: Vector3;

function Start () 
{
	explosionPos = transform.position;
}


function OnTriggerEnter (other : Collider)
{
	if (other.tag == "Player")
	{
		other.rigidbody.AddExplosionForce(power, explosionPos, radius, 3.0);
	}
}

Thanks!

Would it help to put the explosionpos slightly above the mine itself?

No, I have tried it.

1 Answer

1

Use the explosion framework provided by unity 3d:

http://unity3d.com/support/resources/unity-extensions/explosion-framework.html

I have tried it, and I my marble still goes up, not backward. I have noticed, that it spins the marble, and shoots it up.

Can you share your updated code? I am certain you simply misunderstood what i meant: if (Input.GetButton("Sprint") && isGrounded) { speed = 36f; } else { speed = 12f; }; if (Input.GetButton("left control") && isGrounded) { speed *= .5f; }