- Home /
how can i make the main cam smooth follow a new prefab that i add after the game start .
how can i make the main cam smooth follow a new prefab that i add after the game start .
i have an aircraft that the cam pointed to , and i want the cam to follow the rocket when i launch rocket from the aircraft .
i need to enter the "smooth follow" script that attached to the main cam , and changing the the transform target var to the value of the new transform (rocket) that i add to the game later.
Answer by deltamish · Nov 01, 2012 at 01:00 PM
Hi,Create a camera add Smooth follow script to it
Add this script to the rocket
var camera:Camera;
var tgt:Transform;//use this in case the rocket is child of another object,assign rocket to tgt
function Start(){
camera.GetComponent(SmoothFollow).target = transform;//tgt if rocket is an child of another object
}
Answer by adrenak · Oct 31, 2012 at 05:52 PM
This is a simple solution :
function Start(){
var cam : GameObject = GameObject.Find("Main Camera");
cam.GetComponent(SmoothFollow).target = transform;
}
Have the above lines in a new script, and add that script to the rocket prefab. The above script assumes that the camera gameobject is named "Main Camera", which you can change.
thank you , i was very helpfully .
i do it in the other way ins$$anonymous$$d
(Camera.mainCamera.GetComponent(SmoothFollow).target = new_player; , your main idea where very helpful even that it didn't works in my code as it is .
Answer by adam_melhem · Oct 31, 2012 at 09:30 PM
THANK YOU MY FRIEND , I HAVE TRY THIS , IT DIDNT WORKS , I THINK THE REASON IS THAT I AM USING NETWORK .
THE MAIN CAM DOESINT BELONG TO THE NETWORK , BUT THE ROCKET BELONG TO THE NETWORK. WHEN THE GAME START ITS START WITH THE MAIN CAMERA BUT AFTER I RUN THE NETWORK SERVER EVERY THING WORKS GREAT BUT THE MAIN CAMERA DOESINT FOLLOW THE NEW NETWORK ROCKET THAT I CREAT AFTER STARTING THE SERVER .!!!!
Answer by adam_melhem · Oct 31, 2012 at 09:31 PM
THANK YOU MY FRIEND , I HAVE TRY THIS , IT DIDNT WORKS , I THINK THE REASON IS THAT I AM USING NETWORK .
THE MAIN CAM DOESINT BELONG TO THE NETWORK , BUT THE ROCKET BELONG TO THE NETWORK. WHEN THE GAME START ITS START WITH THE MAIN CAMERA BUT AFTER I RUN THE NETWORK SERVER EVERY THING WORKS GREAT BUT THE MAIN CAMERA DOESINT FOLLOW THE NEW NETWORK ROCKET THAT I CREAT AFTER STARTING THE SERVER .!!!!
Answer by adam_melhem · Oct 31, 2012 at 09:30 PM
didnt work!!! its network game!!. the rocket will be created in the network game .
Your answer
Follow this Question
Related Questions
How to change Target of camera from Standard Assets 1 Answer
Changing Target Depending On Car Selected 1 Answer
Changing camera target of CarSmoothFollow ( Js to c#) 0 Answers
Switch Smooth Follow between targets smoothly 1 Answer
Cycle through an array? Have Camera Follow different Targets. 1 Answer