- Home /
The question is answered, right answer was accepted
How do I stop the camera from moving after the player dies?
I want to stop the camera from moving so that it stays at the position it is at when the player dies. How would I do this?
With a question like this, it'd be very helpful if you state how you're moving the camera to begin with.
The camera is just moving forward, this is the code: void Start () { GetComponent ().velocity = new Vector3 (0, 0, 7); }
Velocity is applied to an object constantly, just set your velocity to Vector3.zero (0,0,0)
Answer by bhavinbhai2707 · Jan 16, 2018 at 08:09 PM
there are two easy methods you can use 1. cam.position = new vector3(position where you wanna freeze); or, 2. attach a rigid body and freeze x,y,z, constraints of position;
Would this freeze the camera entirely? I need the camera to move in the beginning and then freeze only when the player dies.
just trigger those steps only when player dies
if(playerdied)
{
stopCam();
}
void stopCam()
{
cam.position = new Vector3(cam.position.x,cam.position.y,cam.position.z);
}
and simply stop calling stopCam function when done!! eg:- playerdied = false;
I did something similar to this and it worked! Ins$$anonymous$$d of having a new Vector3 with position, I used cam.velocity = new Vector3(0,0,0) and this worked. Thank you so much!
Answer by PersianKiller · Jan 17, 2018 at 04:48 PM
you should check player health ,if it falls to 0 , then stop your camera :).
for example (a healthManager script)
public int Health;
public void GiveDamage(){
Health-=Damage;//
if(Health<=0){
//Stop Camera
}
}
How would I stop the camera? Can you provide a basuc example for the //Stop Camera part please.
it's a very simple 2D example.watch this .it might be helpful.its about how to create a health$$anonymous$$anager and camera$$anonymous$$anager and stop the camera when the player dies.
part1
part2
Thank you for the tutorials! $$anonymous$$y character doesn't really have health so this didn't apply to me, but I watched this and I'm sure it will help me in the future!
Follow this Question
Related Questions
Issue with clamping camera 1 Answer
Cinemachine Confiner 2D shift my camera view 0 Answers
Keeping the camera in bounds 1 Answer
Why Do I Have Camera Stutter? 1 Answer
3rd Person Orbit Camera in LOCAL Space 0 Answers