playMaker

Author Topic: Limiting Translation to a certain distance  (Read 5625 times)

Neptune_Imaging

  • Playmaker Newbie
  • *
  • Posts: 27
Limiting Translation to a certain distance
« on: February 23, 2013, 02:59:15 PM »
Hey everyone, I have a question in regards to setting up an object that will be in a viewer, and what I want to happen is once I get close enough to the object, such as zooming in, I would like for it to stop at a certain distance. I already have the setup done, I just need to set up a limiter so that it will stay on screen no matter what I do.

Also, how would I go about setting up a proper reset switch to put the model back where it was... I have a game object that this whole set up is attached to called "Gimble", and I added a state called "reset", and I used reload level, but i am sure there is a more optimised way...

And final question is, in this viewer, I want to switch between two models, that are already in the scene (or prefabs). How would I go about switching the models, mainly just swapping them out...

Thanks a bunch.

Neptune_Imaging

  • Playmaker Newbie
  • *
  • Posts: 27
Re: Limiting Translation to a certain distance
« Reply #1 on: February 23, 2013, 06:31:52 PM »
Okay, i have the viewer set up, and I found activate game object, but when I run playmaker, I want one model hidden and the other visible... and when I press a key, i want the second model to show and vice versa... when I run the viewer, both models show until I hit the S key...

EDIT: The prefab is not active, but the meshes that belong to that prefab are still showing... I want to hide everything on that prefab...
« Last Edit: February 23, 2013, 06:47:47 PM by Neptune_Imaging »

Neptune_Imaging

  • Playmaker Newbie
  • *
  • Posts: 27
Re: Limiting Translation to a certain distance
« Reply #2 on: February 26, 2013, 01:28:58 AM »
Bumping this topic... here is the web player that i put together using Playmaker... only problem I have though is trying to limit the distance the user can zoom in and out as well, as panning...

https://dl.dropbox.com/u/158971/Blade/Model%20Viewer/WebPlayer/WebPlayer.html

A/D Rotate Left and Right
S Switch model
Q Reset Model
Left/Right Arrow Zoom in and out
Up/Down Pan Up and Down

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Limiting Translation to a certain distance
« Reply #3 on: February 26, 2013, 01:37:33 AM »
After you modify the zoom, use Float Clamp to enforce a min/max value.

Neptune_Imaging

  • Playmaker Newbie
  • *
  • Posts: 27
Re: Limiting Translation to a certain distance
« Reply #4 on: February 26, 2013, 02:11:04 AM »
And where would I place this?


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Limiting Translation to a certain distance
« Reply #5 on: February 28, 2013, 02:29:32 PM »
I assumed you were using a float variable for the zoom/translation.

With your current setup, after the Translate, use Get Position, Float Clamp, then Set Position to clamp the z coordinate.

Or instead of using Translate, you could use a zPos variable and Set Position, and use Float Clamp to clamp zPos.

Does that help?

Cool model BTW!! :)

Neptune_Imaging

  • Playmaker Newbie
  • *
  • Posts: 27
Re: Limiting Translation to a certain distance [SOLVED]
« Reply #6 on: March 01, 2013, 02:01:03 AM »
Thanks Alex... I had a VERY hard time setting the model toggle because it didn't take into account of the hierarchy of the models... and prefabs don't work here sadly, unless you have some ideas.

And I got it to limit the zoom :) Thx a bunch.

EDIT: I had to set the pan up and down to the same values... everything is good now aside from the jittering I am getting... is there a way to stop that...?

EDIT 2: Fixed it... late update was enabled
« Last Edit: March 01, 2013, 02:59:43 AM by Neptune_Imaging »

Neptune_Imaging

  • Playmaker Newbie
  • *
  • Posts: 27
Re: Limiting Translation to a certain distance
« Reply #7 on: April 27, 2013, 05:14:37 PM »
I am sorry to bump this... but I decided to modify this viewer, by setting the camera to the child of a rotating gameobject... the camera will still zoom it, but I want it to always look at the target object, and for the model to keep rotating on it's own as I zoom...

I also want to set up a timer that will resume rotation of the gameobject if there is no input... I assume there is a timer setting I can use for this... thanks a bunch

EDIT: I got it to zoom on the local Z, but during rotation the camera goes off into various directions and I want the camera to keep looking at the model. I have attached a look at to the camera, and set the gameobject as a target...

EDIT 2: I got the zoom working again, just by setting the Get/SetPos to self... now trying to solve the timer issues...
« Last Edit: April 27, 2013, 05:20:43 PM by Neptune_Imaging »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Limiting Translation to a certain distance
« Reply #8 on: May 13, 2013, 06:26:04 AM »
Hi,

 Timer should be ok to implement, the key is to have a fsm dedicated to it.

 from your system you send an event when the user STOP using the feature ( not when it starts, so you need to listen to touch end, cancel or button up/key up)

then you start a timer.

your feature also needs to fire an event when the user starts it, but that's merely to cancel the timer, not to start it.

now, for the timer itself,  I have a very cool "send event from state" action that cou can use here, perfect fit

http://hutonggames.com/playmakerforum/index.php?topic=1249.msg5245#msg5245


catch the end of the user interaction, move a new state, and in that state, use "SendEventFromState" with a timer. It will fire only if it is in that state, SO when the usert start to sue the feature go into a state that does nothing, when the user ends using the feature, move to that state using SendEVentFromState, and it will eventually fire the event IF you haven't exited that state.

Does that make sense?

Bye,

 Jean