- Home /
How to Freeze move camera
How to write script that performs freeze camera (X and Y) when player enter in trigger but without using Time.timeScale.
I tried with:
var mLook : MouseLook ;
mLook = other.GetComponent(MouseLook);
mLook.enabled = false;
but this freeze when a player recently move mouse and not in the position in which I wanted to.
Answer by deltamish · Dec 31, 2013 at 03:01 PM
Well Thats QuiteSimple
Try caching the position first and then apply it to its position
private var _CurrentPos:Vector3;
function OnTriggerEnter(col:Collider)
{
if(col.tag == "Player")//
{
if(_CurrentPos == Vector3.zero)
_CurrentPos = col.transform.position;
col.transform.position = new Vector3(_CurrentPos.x,_CurrentPos.y,col.transform.position.z);
}
}
//Resetting the _CurrentPos
function OnTriggerExit(col:Collider)
{
if(col.tag == "Player")
{
_CurrentPos = Vector3.zero;
}
}
Answer by una_x · Dec 31, 2013 at 05:44 PM
Thank you. I have one question how this script add additional rotation? because this is only position X,Y,Z
please use coment box to post something other than answer and what do you mean by
add additional rotation
Answer by slackz · Mar 10, 2018 at 07:33 PM
Okay, I was playing around with diff options and the dead simplest for me which worked out was simply having a gameManager type script catch pause events, set a simple static variable for that game pause state, and then check for that in your player / camera movement sections. Just don't move player and camera when game state is paused.
My scenario is simple enough not to mess with all sorts of prefabs, etc.
For my needs I needed my dialogue boxes and menus to continue animating, but not having player/camera movement interfere. This worked out swimmingly and feels like the path of least resistance at this point :)