last day (14 days later) » 

10:33 AM
0
A: setting orientation of moving object towards it movement direction

xyLe_You are on the right track, but you should use your movement direction: transform.rotation = Quaternion.LookRotation(movementDirection), as transform.forward is already the objects' orientation. If you do not know/have access to the objects' current movement direction but you know the target pos...

 
movementVector ?
 
The vector with which you are moving the camera. (Like camera.position = camera.position + movementVector)
 
let me find how it is working acutally i dont how object is moving as i am using third party package to move cam on spline
movementDirection should be the position so what is the different b/w transform.position and movementDirection?
 
movementDirection should be the direction in which the camera is moving. The transform.position is translated to the next position (e.g. in each update call) utilizing the movement direction vector. For example: If the camera is moving sideways, the movement direction could be transform.right.
 
how can i find the direction? is this rotation
 
10:33 AM
can you provide the code that moves your camera?
 
nope it is a package script
 
does that package provide some sort of documentation
 
hey
 
thanks for your time
 
10:34 AM
is that a free or paid package that you are using?
 
paid
megashape trainfollow
megaTrainFollow Script
 
hm ok, and how does the code look to move your camera?
 
actually having issue with rotation of the camera which moving on the spline. it something like this car.carriage.transform.position = car.cp + car.carriageOffset;
 
you would need either the point on the spline the camera is currently moving to or some kind of velocity vector
 
10:39 AM
unfortunately i dont know that package, so i dont really which of these it provides
 
its ok i have each spline last point in vector3 format now what to do?
camera object is moving on spline while i have spline's last vector3 position
 
ok, do you know which of these vector3s is the current target?
 
current target? one spline constituite with different vector3 i know about last vector3 only while i also don't which spline point have passed and which to come
 
hm, that is unfortunate, you would need to know which spline point would be passed next
 
hmm ok i try it and need to identify
and then next?
 
10:45 AM
say you know that next spline point (call it target), then you rotate you camera with transform.rotation = Quaternion.LookRotation(target - transform.position)
more general: you calculate the vector that is pointing from the cameras current position to the next spline point and pass it into the LookRotation function
 
hmm that is fine. I have array of spline position but currently don't know which point on I am and which is the next. I am trying to identify it
 
ok, hm maybe there is some better way. when the script package moves your object via a rigidbody component, you could read the movement direction from that as well
 
no there is no rigidboxdy
 
alright, then you will have to keep track of the spline points somehow
sorry but i have to go now. good luck with you project, i hope you can make it work
(and if it works, consider accepting my answer on stackoverflow :) )
 

last day (14 days later) »