- Home /
Mouse Orbit + Move Object + Follow Problem
Scripts Tweaked/Used: MouseOrbitImproved.js MoveObject.js
First of all, I tweaked the MouseOrbitImproved script so that instead of Last Update
I used Update
function.
I attached this MouseOrbitImproved script to the Main Camera, whereas the target is an empty Game Object. I attached the MoveObject script then to this empty object, but tweaked a bit such that it reads the current position of the empty object and passes another position (upon clicking different colliders located on a map) for this object to travel to.
I was successful in combining the 2 scripts. I was able to make a camera follow an invisible trail towards a next object (while allowing the camera to orbit that invisible object while it is moving), depending on which I click on, however, I would like to control the rotation of the camera by holding a mouse button and dragging. I already tried adding && Input.GetMouseButtonDown(0)
to the target
under function Update()
, but it doesn't work.
What do you think I must do to make it work?
Answer by aldonaletto · Nov 17, 2011 at 12:10 PM
GetMouseButtonDown only occurs once; you should use GetMouseButton to have true returned while the mouse button is pressed, and false when not pressed.
Hi, it solved one part of the problem. Changing it to Get$$anonymous$$ouseButton worked, however, when the target is moving, now I also have to hold the mouse button for it to move. :(