playMaker

Author Topic: Camera functions?  (Read 4525 times)

Ansem

  • Playmaker Newbie
  • *
  • Posts: 3
Camera functions?
« on: May 29, 2011, 01:55:59 PM »
Hi all.

Well, I'm working on getting my camera set up properly. I'm particularly interested in being able to rotate around my character by clicking and dragging the right mouse button and also being able to sort of zoom in/out using the mousewheel.

Anyone know how to accomplish this in Playmaker? I know I can add some scripts with the same functionality, but I'm more interested in seeing if it can all be done with PM, and more importantly how. Few tests I've done so far haven't gone quite that well :P

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Camera functions?
« Reply #1 on: May 31, 2011, 06:36:41 AM »
Hi,

 Ok. Try to cut down the problem is small chuncks.

Rotating character:
Can you describe what exactly you can't work out? is the dragging of the mouse itself? the link to the transform to rotate it, the state and actions set up itself?


Zooming: try the following:

 in a clean fsm attached to the camera:

1: select the start state
2: create a float variable "delta zoom"
3: add a get axis action
4: the input you want to watch is "Mouse ScrollWheel" ( in the input settings of unity itself)
5: output to "delta zoom" variable
6: add a second action "translate"
7: set the z component to "delta zoom"

and you have a basic working zoom.

If you need more help, don't hesitate,

 Bye,

 Jean

Ansem

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Camera functions?
« Reply #2 on: May 31, 2011, 09:17:08 AM »
Thanks so much for the zoom help. After some playing with it I was even able to give the camera a bit of inertia when zooming, very cool! ;D

As for rotating the camera around my character, yes I'm still stuck.

I'm trying to get the camera to rotate around my character in what is basically a big circle. But only when I right click and drag with the mouse.

I'm trying to use Get Axis Vector and I set the relative option to my character mesh (Am I already way off track here?). I got it so that it actually does rotate with the rotate action. But it just continues rotating on it's own as long as the right mouse button is held down. It doesn't actually move along with my mouse movements.

Trying other Get Axis commands just rotates the camera in odd ways, none of which are actually centered around the character.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Camera functions?
« Reply #3 on: June 01, 2011, 06:05:15 AM »
Hi,

 What you need is record the delta translation of the mouse, that is each frame get the new mouse position and substract the previous. You use that value to rotate the camera. Then if the mouse is not moving, the delta movement is null and the camera doesn't rotate.

 It seems you are willing to sort this. So I leave you in your juice for another post  ;D  this is anyway the best way for you to learn.

check this post, it does delta transalion but from a plane in 3d, you can adapt this for a delta translation on screen.

http://hutonggames.com/playmakerforum/index.php?topic=270.msg1092#msg1092

If you more need help, drop a reply and I'll make a working example.

 Bye,

 Jean

 

 

MaDDoX

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 165
    • FluidPlay Studios
Re: Camera functions?
« Reply #4 on: June 04, 2011, 07:41:16 AM »
As for rotating the camera around my character, yes I'm still stuck.

I'm trying to get the camera to rotate around my character in what is basically a big circle. But only when I right click and drag with the mouse.
The best approach to have concurrent actions from different, concurrent inputs is simply have two different FSMs on the same object, one responsible for each. That's because states are always "unique", they don't happen simultaneously with any other state, so if you want to have it all in the same FSM you're forced to account for every possible combination of your different inputs - ie. insta-spaghetti. So, for instance, if you want a left-right controller you put it in the same FSM (since one direction "cancel" the other), but if you want to add forward-back control without losing the left-right control you add a second FSM to do the forward-back. Same thing with some shoot or jump action.

Capisce? :)
--
Breno "MaDDoX" Azevedo
@brenoazevedo