- Home /
Smooth Attached Object movement
Hi, I'm creating a VR game and I want to attach the space ship to the camera so it moves with it but its to static, I want to make it more realistic, it could be limitate the Y and X to a lower speed but I don't know how. Could You Help Me? I speak Spanish so I don't write that good :) Thanks. C# is Beter.
I have this so the Space Ship with the camera could move:
 public float Speed;
 public GameObject SpaceShip;
 void Update()
 {
     SpaceShip.transform.Translate (Vector3.forward * Speed * Time.fixedDeltaTime);
 }
Is realy short
Answer by iabulko · Sep 21, 2016 at 01:29 PM
Read a little about Lerp function, it's really usefull in situations like this. Here try this:
 Transform mainCamTra;
 void Start()
 {
     mainCamTra = Camera.main.transform;
 }
 
 void Update()
 {
     mainCamTra.position = Vector3.Lerp(mainCamTra.position, spaceShip.transform.position, 0.9f);
 }
PS: And remember to write variable names starting with small letter in C# ;> spaceShip, not SpaceShip ;]
Your answer
 
 
             Follow this Question
Related Questions
FPS camera movement breaks GameObject 2 Answers
How to smoothen movement of a child object? 1 Answer
Camera Relative Movement 2 Answers
smooth rotation / movement ? 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                