Hey all, I’ve been pondering lately how to do a 3rd to first person camera movement, like in legend of zelda, when you use your bow. Would you h ave an empty game object then tell the camera to move to that gameobjects position? If so whats the js script for that (transform.position = gameonbect.position)…?? Maybe that’s the wrong way all together, Any advice would be appreciated.
well this isnt the bets way, but you could have 2 points. The first point is at the position you want for the 3rd person and the second point is at the position of the bow(well just behind it so it has the aiming effect). Now when you press a key, in this case a, the boolean value is changed. And now since we have this done we can make it move, well change positions.
Heres a snippet of code:
var firstPerson : boolean = false;
var Point1 : Transform;
var Point2 : Transform;
var Cam : Camera;
function Update(){
if( Input.getKeydown("a")){
firstPerson = true;
}else{
firstPerson = false;
}
SwitchPos();
}
function SwitchPos(){
if(firstPerson){
Cam.transform.position = Point2.transform.position;
}else{
Cam.transform.position = Point1.transform.position;
}
}
Now im not 100% sure this is correct syntax, but it should work.
The syntax is sound. However, instead of initializing a Camera object, you would likely need to create a variable that references the camera object already in your game.
EDIT: I’m an idiot, he made the camera variable public, so you can drag any camera into the editor. My mistake. Yep, the code should be perfect! Sorry for trying to taint your good name Anthony!
awesome thanks so much, looks like it’ll take a little bit of work to make it perfect, but I think I can get it.