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.
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
}
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 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 .!!!
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 .!!!
didnt work!!!
its network game!!.
the rocket will be created in the network game .