Hi,
ok,
Here is a package with a prefab for moving the camera when dragging the mouse in 3d.
WARNING: there is an issue with prefabs. you'll likely get an error with the get position action. I just don't understand this error. so here are the step to make it work.
So Alex, if you read this. I know you are very very busy with 1.2 so don't worry too much right now about this as I have a fix, but if I could get to the bottom of this issue, that would be great, hopefully, this is something trivial.
1: import the package attached to this post
2: drag the prefab in the hierarchy view
3: delete the prefab itself from the project view ( this will keep the scene hierarchy intact, so you won't loose what's in the scene)
4: then that works...
Don't forget to add a cube or some elements in the scene to witness the camera movement as you drag.
Explanations about how it works ( I'll make a tutorial on the wiki section when I have time).
I have build a special custom action for the drag that is independent enough to be reusable. This also allow for some playmaker fsm goodness.
http://hutonggames.com/playmakerforum/index.php?topic=272.msg1087#msg1087I have also built a vector3 operator custom action to allow for vector additions and subscraction. This was needed for the algorithm.
http://hutonggames.com/playmakerforum/index.php?topic=271.0 So one fsm ( drag ) is responsible for checking if mouse is down and if so dispatch a drag event and start the drag. During the drag I check for mouse up and exit the drag state if so. while dragging, I record the world position of the mouse in the plane defined in the drag action and also record the drag vector. The drag vector is what will be used to move the camera.
The second fsm ( position ) listen for the drag events and when starting record the start position for reference and then poll the drag vector value from the drag fsm and substracts it to the start position.
If you are curious and tests the performances, make sure you close the playmaker editor AND the inspector if showing the fsms. With editor and inspector, I drop from 1200 fps to 500 when dragging... when editor and inspector closed, almost not difference!!!! so be aware of this.
I have in purpose separated each features as much as possible. for example, the drag action doesn't need to on a camera gameObject. The position fsm can control any objects too. The mouse position is not the only way to control the drag action , you simply inject a screen position, so it's kind of ready for touchscreen and you would only modify the way you get the screen position that is used by the drag action. All this can be perceived as more complex than it needs to, but in the long run, this gives more flexibility and things are more reusable.
If you have any questions or issues, don't hesitate. Bear with me for a more descriptive tutorial on this. This is a good case for intermediate level, so this will go in the tutorial section of the wiki.
Bye,
Jean