playMaker

Author Topic: Limit Look at Rotation[SOLVED]  (Read 4162 times)

foxdeltagames

  • Junior Playmaker
  • **
  • Posts: 62
    • View Profile
Limit Look at Rotation[SOLVED]
« on: August 01, 2014, 03:27:21 PM »
Hi guys, I was am wondering if this request can done.

Is there a way to make a rotation limit to "look at" or "Smooth look at"?
It will be the same as both actions, but gives the user a option to put a limit on the Y, X, and Z axis.

For example, for my mech game I need the mech head to look at the player, but as the way it is right now. it will look at the player while rotating a whole 360. In my game I need the mech's head to only do 180 turns from left to right.

and maybe have store float options.

Thanks guys.
« Last Edit: April 09, 2018, 10:53:54 PM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13321
  • Official Playmaker Support
    • View Profile
Re: Limit Look at Rotation
« Reply #1 on: August 08, 2014, 12:06:32 PM »
Hi,

 I am not aware of a playmaker action to do this, and I am also in need to something like that pretty soon, funnyly enough. So it will come up, but it's quite complex to deal with limits, I'll have to experiment.

 Please bump this thread beginning of september, Unite and PAX is getting closed and I have to focus on few things currently for the occasions.

 Bye,

 Jean

foxdeltagames

  • Junior Playmaker
  • **
  • Posts: 62
    • View Profile
Re: Limit Look at Rotation
« Reply #2 on: September 04, 2014, 04:20:15 PM »
I am bumping this post like you asked for :)

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • View Profile
    • My Blog
Re: Limit Look at Rotation
« Reply #3 on: September 09, 2014, 10:02:45 PM »
Bump, came across this need today. Got some turrets that need clamped rotation using smooth look at. It would be nice to have some kind of limits based on the local rotation.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13321
  • Official Playmaker Support
    • View Profile
Re: Limit Look at Rotation
« Reply #4 on: September 23, 2014, 01:20:07 AM »
Hi,

 Working on it. I am leaning towards a custom action that bound a float within a min and max to be reusable across a lot of cases. More on this very soon.

 Bye,

 Jean

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • View Profile
    • My Blog
Re: Limit Look at Rotation
« Reply #5 on: September 23, 2014, 07:59:24 AM »
Sounds awesome. It'll be perfect for my turret stuff. Think you can make a world/self space toggle?

ivam

  • Playmaker Newbie
  • *
  • Posts: 34
    • View Profile
Re: Limit Look at Rotation
« Reply #6 on: September 27, 2014, 12:46:39 AM »
bump

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3370
    • View Profile
    • jinxtergames
Re: Limit Look at Rotation
« Reply #7 on: July 31, 2015, 10:28:22 AM »
hmm, it seems this has been forgotten,
searched Ecosystem but no result....

sooo... ill just give it a Bump :)

foxdeltagames

  • Junior Playmaker
  • **
  • Posts: 62
    • View Profile
Re: Limit Look at Rotation
« Reply #8 on: November 12, 2015, 07:05:15 AM »
Just giving it a little bump

18LSC

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Re: Limit Look at Rotation
« Reply #9 on: March 13, 2018, 08:24:42 AM »
Bump an old post but it's the only one I found with a mod saying they were actually making this custom code... did it ever come out? :/

Or has this been solved elsewhere? I also want a "smooth Look at" with a rotation limit on X/Y based on what you set position for zero (facing forward) is, for turrets or security cameras that follow the player, but wont clip through the wall its attached to.
So in that case I'd only want 180 degrees left to right, maybe 90 up and down limit.

I'm stumped on how to make this myself.  :(

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13321
  • Official Playmaker Support
    • View Profile
Re: Limit Look at Rotation
« Reply #10 on: March 14, 2018, 12:11:08 AM »
Hi,

 Woah, seems to have miss that post over and over again :)

I'll have a look at this.

 Bye,

 Jean
 

18LSC

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Re: Limit Look at Rotation
« Reply #11 on: March 14, 2018, 02:49:39 AM »
Hi,

 Woah, seems to have miss that post over and over again :)

I'll have a look at this.

 Bye,

 Jean

Thank you Jean :) I look forward to using this in my project
« Last Edit: March 14, 2018, 04:18:46 AM by 18LSC »

GonerGames

  • Playmaker Newbie
  • *
  • Posts: 36
    • View Profile
Re: Limit Look at Rotation
« Reply #12 on: March 15, 2018, 08:35:45 AM »
There are Look At and Smooth Look At actions.
To prevent it from rotating into a wall or object I use a float compare. When x/y > or < the area of rotation limit, we move to a second state that stops the turret/camera following the player.
Simple Setup:
1st State: (make sure every frame is selected on all)
Get property on turret x/y rotation - store in float value "rotation"
Float compare - "rotation" > 90 -> go to 2nd state -  this is your upper limit of rotation
Float compare - "rotation" < 0 -> go to 2nd state - this is your lower limit of rotation
Look at or Smooth Look At -> Player Object

2nd state:
 To get it to re-activate, should the player re-enter the area, here are a couple of options:

1. Have an empty game object inside your turret that continues to look at the player. This object will rotate without affecting your actual turret. Track its x/y rotation and do a float compare. When the values are within range then go back to your tracking state.

2. Have 2 colliders that are being checked for onTrigger. One at the top range and one at the bottom range and when the player enters go back to your tracking state.

Hope this helps.



18LSC

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Re: Limit Look at Rotation
« Reply #13 on: March 18, 2018, 04:38:11 AM »
There are Look At and Smooth Look At actions.
To prevent it from rotating into a wall or object I use a float compare. When x/y > or < the area of rotation limit, we move to a second state that stops the turret/camera following the player.
Simple Setup:
1st State: (make sure every frame is selected on all)
Get property on turret x/y rotation - store in float value "rotation"
Float compare - "rotation" > 90 -> go to 2nd state -  this is your upper limit of rotation
Float compare - "rotation" < 0 -> go to 2nd state - this is your lower limit of rotation
Look at or Smooth Look At -> Player Object

2nd state:
 To get it to re-activate, should the player re-enter the area, here are a couple of options:

1. Have an empty game object inside your turret that continues to look at the player. This object will rotate without affecting your actual turret. Track its x/y rotation and do a float compare. When the values are within range then go back to your tracking state.

2. Have 2 colliders that are being checked for onTrigger. One at the top range and one at the bottom range and when the player enters go back to your tracking state.

Hope this helps.

I actually ended up figuring out almost that exact setup using 2 states too lol, but my worry is performance cost, having 2 objects tracking the player constantly, multiplied over maybe 10 or so turrets/cams etc, it works but would you say its bad for performance?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13321
  • Official Playmaker Support
    • View Profile
Re: Limit Look at Rotation
« Reply #14 on: March 21, 2018, 03:33:22 AM »
Hi,

 I am on it, but I haven't found yet the best way to go about this as it's either to complex to setup or too limited in possibilities, so I'll keep trying.

 Bye,

 Jean