- Home /
 
               Question by 
               SerujiShard · Nov 10, 2018 at 01:06 PM · 
                ballrespawnfall  
              
 
              When my Player respawns, it does not stop moving (it's a ball).
Hi All! How can I do so when my respawns character stops moving, I have teleported after a fall and the character goes ahead (the Player is a Ball).
 public Transform respawnTarget;
 public GameObject thePlayer;
 void OnTriggerEnter(Collider other)
 {
     thePlayer.transform.position = respawnTarget.position;
 }
               Comment
              
 
               
              Answer by engfkaplan · Nov 11, 2018 at 01:15 PM
You can set zero angular velocity in rigidbody when teleport ball.
 Rigidbody ballRigidbody = GetComponent<Rigidbody>();
 ballRigidbody.angularVelocity = 0;
I have this on my Respawn code (i'm new in C# i don't understand a lot):
public Transform respawnTarget; public GameObject thePlayer; void OnTriggerEnter(Collider other) { thePlayer.transform.position = respawnTarget.position; }
 public Transform respawnTarget; 
 public GameObject thePlayer; 
 void OnTriggerEnter(Collider other) 
 { 
 thePlayer.transform.position = respawnTarget.position; 
 
 //Get player rigidbody component
 Rigidbody ballRigidbody = thePlayer.GetComponent<RigidBody>();
 //Set angular velocity to 0
 ballRigidbody.angularVelocity = 0;
 }
if you are making 2d game then use
 Rigidbody2D ballRigidbody = thePlayer.GetComponent<RigidBody2D>();
ins$$anonymous$$d of
  Rigidbody ballRigidbody = thePlayer.GetComponent<RigidBody>();
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                