How to stop force on an object

I want it for my respawn script. As of right now when the object respawns it still has the force that was applied to it before it respawned. Any help would be appreciated. Thank you.

private var lowPoint: int = 15;

private var respawnPoint : Vector3 = new Vector3(50, 21, 54);

private var respawnRotation: int = 280;



function Update()

{



	if(transform.position.y <= 15) 

	{

		transform.position = respawnPoint;

		transform.rotation.y = respawnRotation; 

	}

}

just use rigidbody.velocity = Vector3.zero?

2 Likes

That didn’t work:/

hmm, is attached to the character right?

correct

Hmm, if it’s using a rigidbody that should stop it

I have tried rigidbody.velocity = Vector3(0,0,0) which i am assuming is the same as .zero? that didnt work either

I’m sorry, i don’t pretend to be an expert, but what’s actually causing the force, cause I tested it and it seemed to work?

It’s cool, this is my first month:) An explosion connected to an instantiation of a sphere is what is causing the force.

Actually, I think it is working. But the object falls over after respawning. Which is an improvement, he used to go flying lol.

well celcome to Unity :), yeah i’m not sure why it’s not stopping, you sure the explosion only fires once? I’m not really sure what to tell you. You could try putting rigidbody.velocity = Vector3(0,0,0); into the Update() function and seeing if it’s that part that isn’t working?

Do you know why the object would fall over after respawning?

? What are you using for the charcter, a character collider or something different?

collider and rigidbody

no lol, i mean what kind of collider? if it falls over it can’t be a character collider right?

ah lol capsule collider

oh, ok. So as you said the capsule keeps moving even after it respawns? And the script moving it, isn’t still applying force?

I’m not sure what else to say, stop the movement with rigidbody.velocity = Vector3(0,0,0); and wait, did you also stop the torque? Sorry i guess i never thought of that! :slight_smile: rigidbody.angularVelocity = Vector3(0,0,0);

The force situation was resolved. That code worked. But now when the object and all of its components respawn they fall over like its top heavy or something.

i don’t know what to say, if you don’t want it to fall over, give it a character collider, or when it respawns reset the rotation?

1 Like