I need help with stopping the momentum when i respawn ,I need help with stoping the momentum when the character respawn
I am trying to make my own game but when i respawn the momentum keeps going please help! ( i tried with another post here but it didn't work
Code:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class respawn : MonoBehaviour { [SerializeField] private Transform player; [SerializeField] private Transform respawnPoint; private Rigidbody Rigidbody;
void FixedUpdate()
{
if (player.transform.position = respawnPoint.transform.position);
{
GetComponent<rigidbody>.velocity = 0;
Rigidbody.angularVelocity = 0;
}
}
private void OnTriggerEnter(Collider other)
{
player.transform.position = respawnPoint.transform.position;
}
} ,Can someone help with the code here is what i tried its my fist game and i really want it to work (i saw another post about this but it didnt work for me :/
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class respawn : MonoBehaviour { [SerializeField] private Transform player; [SerializeField] private Transform respawnPoint; private Rigidbody Rigidbody;
void FixedUpdate()
{
if (player.transform.position = respawnPoint.transform.position);
{
GetComponent<rigidbody>.velocity = 0;
Rigidbody.angularVelocity = 0;
}
}
private void OnTriggerEnter(Collider other)
{
player.transform.position = respawnPoint.transform.position;
}
}
maybe a good trick i to disable the rigidbody for one frame.
Your answer
Follow this Question
Related Questions
Player loses momentum when landing 0 Answers
Face direction of a Vector 3 1 Answer
Character movement 0 Answers
FPS movement with momentum 1 Answer
Implementing a "flyer" game in with the old CardBoard Google sdk 2 Answers