playMaker

Author Topic: Simple question: Wheres the Scroll Wheel stuff? [SOLVED]  (Read 7021 times)

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Simple question: Wheres the Scroll Wheel stuff? [SOLVED]
« on: March 08, 2013, 09:06:04 AM »
Thats it really, making camera controller now, and need to zoom in and out using scroll wheel.. cant find it... been looking all over... for at least ooooh 10 minutes...
« Last Edit: March 11, 2013, 12:51:14 AM by Alex Chouls »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #1 on: March 08, 2013, 09:39:34 AM »
Use Get Axis with "Mouse ScrollWheel":
https://hutonggames.fogbugz.com/default.asp?W192

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #2 on: March 08, 2013, 03:09:53 PM »
Thanks Alex.. found it... but er..
how do you use it?

I just added Smooth Follow Action, and want the scroll to zoom the distance setting.
Tried 2 things.
1) Stored the scroll wheel as VarScrollwheel and put that ins the distance of Smooth Flow Action... didnt work...  bit of jerking is all.
2) I could see that the scroll wheel went back to 0 after every twizzle of the wheel (twizzle = technical term meaning to scroll the wheel) SO I made a new Var VarZoom then added the Scroll wheel to that using Float Operator

still nothing.. confused here..

M

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #3 on: March 08, 2013, 03:32:48 PM »
Mouse ScrollWheel gives you the amount the mouse wheel was moved.

You're on the right track adding this to a variable, you probably just need to multiply it for larger changes...

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #4 on: March 09, 2013, 07:14:13 AM »
Quote
You're on the right track

Well Im glad to hear THAT Alex!!
 but more fiddling hasnt really got me anywhere.
So I thought I post the specifics of my solutions and see if you can find a detail Im overlooking.

IM using 3 variables:
VarScrollWheel,whichs is just the stuff IM getting from the mouse scroll from Get Axis
VarScroll Which is an abitary number I hoped to ADD and subtract the VarScrollWheel from, adusting the default number could tweak the effect.
VarZoom The result of the addition of these two Vars, that IM feeding the components for zooming.

This I tried 2 ways

First version: SEE IMAGE ONE
Where I try to use the scroll wheel add that to a var, and then use the total of THAT addition in the distance parameter of the Smooth Follow Action. (This is the way I want my camera to follow may camera, and may be my downfall?)

The result is that when I use scroll wheel, it wobbles a bit, bit always returns to the original amount, so my mousescroll does NOT seem to be being added (or subtracted) from my scrolltotal variable.

Second version: SEE IMAGE TWO
I read in http://hutonggames.com/playmakerforum/index.php?topic=293.0 where Jean tells someone else to use translate to move the camera, so I try that instead.

However the same result, slightly different, not so jerky, and I can see that its trying to pull back or pull in, but always reverts immediately to the default number.. so my addition isnt working...

HELP!!

Mark

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #5 on: March 09, 2013, 09:51:43 AM »
I 'm not sure what you're trying to do with varScroll...

Just add varScrollWheel to varZoom.

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #6 on: March 09, 2013, 10:01:28 AM »
The second image without the smooth follow would work fine except for that you'd need to change the mode of the float operator to multiply.
The first one needs 2 float operator : 1 to multiply the axis values, another to add that magnified value to the current value (you used in the previous frame in the smooth follow action).

Float multiply (AxisValue * 10)
Float add (currentValue + AxisValue)
SmoothFollow(distance = currentValue)

all every frame. change the value of currentValue to change the start distance.

The axis action resets itself to 0 after each frame. It only shows the difference between the last frame and this frame, not the cumulated value of all the wheel rotations from when the game starts for the first time to now.
Was that what caused confusion here?
« Last Edit: March 09, 2013, 10:19:32 AM by kiriri »
Best,
Sven

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #7 on: March 09, 2013, 12:57:11 PM »
Thanks guys,
@ Alex:
Quote
Just add varScrollWheel to varZoom.
Im sure Ive tried that... but, as Kiriri I think explains, as the axis resets itself after every frame I need to add that amount to something, which is what I thought I was doing with this extra variable, but maybe thats not necessary.

@kiriri
Thanks so much for the in depth, gonna take me a bit to understand, but I WILL.. Im going thru it now.
BUT you said
Quote
The second image without the smooth follow

And I must say that I NEED the smooth follow, cos thats what my character needs to hove to have the camera follow him, so what did you mean? If I remove it, it would work? But I need it!!! Or is there a better way?

MArk

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #8 on: March 09, 2013, 01:13:45 PM »
I probably just misunderstood the translate action, I thought that's what you used to zoom.

ok , everything else aside, use this setup:
(comments after the //)


GetAxis (to AxisValue) // get the value for this frame. This may be just 0.01
Float multiply (AxisValue * 10) // multiply the axis value to something usable. Changing the camera distance by only 0.01 would be barely noticable.
Float add (currentValue + AxisValue) // add the zoom value of this frame to the current distance value. If you didn't zoom this frame, it will add 0, so nothing changes.
Float Clamp (minZoom < currentValue < maxValue) // use this action to stop the camera from zooming off too far or from zooming to close.
SmoothFollow(distance = currentValue) // well, that should be clear :D

There you go, that's all there is to it in the end :) Hope this helps with the understanding part ;)
Best,
Sven

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #9 on: March 09, 2013, 03:19:45 PM »
WOW thanks Sven...

Im totally getting what you are doing here, just that I must be doing something wrong, if you wouldnt mind taking alook at the pic. as you can see the FLoat Add doesnt seem to be lit green, so is not firing.. I have no idea why.

I was going to make this i video so you could see what happens with the numbers, but I can explain. Its just the scrollwheel numbers (as you say something like 0.0162762) that are appearing in the Get Axis Axis Name box, the Float Multiply Float Variable box and the Float Add Float Variable box...

Mark

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #10 on: March 09, 2013, 03:49:28 PM »
you forgot to check "every frame". Without that it runs a single time only.
So in frame 2 PlayMaker again runs all the actions from top to bottom, but this time it leaves out any action that does not have everyFrame checked (this is only a figurative model). [same in any subsequent frame from then on of course]

Are you an artist? Always helps to know that for explanations :)
« Last Edit: March 09, 2013, 03:51:37 PM by kiriri »
Best,
Sven

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #11 on: March 09, 2013, 04:03:49 PM »
Quote
Are you an artist?
Wouldn't quite go that far!

...but a coder I ain't!


But... I click Every Frame.. no difference... (Except Add Float becomes green whole time)

Im really stupt by this... Is it still the AMOUNTS a so small and not getting multiplyed enough?

M
« Last Edit: March 09, 2013, 04:08:38 PM by markfrancombe »

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #12 on: March 09, 2013, 04:17:42 PM »
WAIT!!
I noticed that Add Float just does the same as multople, it does its job and passes it on down the stack... doesnt accumulate anything to anywhere.. so swapped AddFloat for Float Operator, and
BINGO!
It works..
Now I have to say.. its not pretty.. it jumps in big 'orrible steps depentant on each "click" of the scroll wheel, not nice and smooth... Im hoping I can fix that by just fiddling with the numbers a bit, but if not, is there a sort of FloatSmooth Action or something??

Mark

By the way Kiriri, you are a star! Thanks for your help on this one... oh and..the name.. "Sven".. ikke Norsk er du? fordi, kansje I kjøpe deg et øl?

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #13 on: March 09, 2013, 04:43:47 PM »
nei, jeg er tysk.
And next time I'll visit Norway I'll be sure to take you on your offer :P

Add float adds the second value to the first. Maybe you had them the wrong way round?

As for the big jumps  and stuff, it's hard to get that right. If you use tween actions they will behave weirdly if you zoom multiple times in subsequent frames.
So what I personally use is a rigidbody driven camera setup. I'm working on an rts, and that also works for nice up/down/left/right movements.

So first of all I added a rigidbody component to my camera and set the drag property to 2. This will make it stop smoothly but still rather swiftly after applying force to it.
Then as for my Fsm, it's just a GetAxis + floatMultiply + ForceAdd(self z axis) State.
The exception here is that you can't clamp the force add to clamp the camera position. Instead you need to use:

getPosition(get the self Z every frame as "Z value")
clampFloat(minDistance < Z value <maxDistance)
setPosition(every frame, self , Z as "Z value", lateUpdate)
 
You can just put those states right under the other ones, as long as they run after the force add. If the current z value is not below or above the min/max values it's not clamped, so you will just set the position to the same value it already is at, which does nothing. If you're too far away or too close, this effectively nullifies any further rigidbody movements.
Best,
Sven

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Simple question: Wheres the Scroll Wheel stuff?
« Reply #14 on: March 10, 2013, 04:03:20 PM »
Im pretty happy with the way it finally worked out, so for now IM going with that, but I have to say I would like to know what you meant here, didnt quite follow.

In your example, this FSM is on the camera, right? NOT the character? (Im putting all my stuff for user interacting on the character. An the example youa re giving, is this how you are doing ALL your camera follow stuff? Any chance of a screenshot?

I tried a wuick mock up and my camera just fell thru the geometry! I haven't used Fore before so I don't know how that works, or what you are using it for here.