playMaker

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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14500
  • Official Playmaker Support
    • View Profile
Re: Limit Look at Rotation
« Reply #15 on: March 26, 2018, 02:40:23 AM »
Hi,

 ok, success :)

 can you try this action o the Ecosystem: ClampRotation

you add that after the Lookat action ( lookat does it works, and then this action will constraint, so the order is important).

 I made this as a separation action, because it has a lot of usage, not just for look at.

 I also let you define the default local rotation, otherwise the action takes the current rotation as the default rotation to base its clamp and for the lookat, it would not work, as look at executes first, so the clamp would be around the newly rotated object, and that's wrong. you can modify the default rotation in real time, clamping will adjust :) and if you want to constraint on all three axis, then have 3 of these actions one for each axis.

 Let me know how it goes. If all is good, I'll wrapp it up with a nice editor debug lines to see what's going on in the scene view.

 Bye,

 Jean

18LSC

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Re: Limit Look at Rotation
« Reply #16 on: March 27, 2018, 06:32:30 PM »
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

Thank you for spending time on this I really appreciate that

18LSC

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Re: Limit Look at Rotation
« Reply #17 on: March 29, 2018, 04:51:09 PM »
Hi,

 ok, success :)

 can you try this action o the Ecosystem: ClampRotation

you add that after the Lookat action ( lookat does it works, and then this action will constraint, so the order is important).

 I made this as a separation action, because it has a lot of usage, not just for look at.

 I also let you define the default local rotation, otherwise the action takes the current rotation as the default rotation to base its clamp and for the lookat, it would not work, as look at executes first, so the clamp would be around the newly rotated object, and that's wrong. you can modify the default rotation in real time, clamping will adjust :) and if you want to constraint on all three axis, then have 3 of these actions one for each axis.

 Let me know how it goes. If all is good, I'll wrapp it up with a nice editor debug lines to see what's going on in the scene view.

 Bye,

 Jean

Gah sorry I missed your last reply when I posted my last! xD, thanks so much for working on this

I tested it today, and I'm not the wisest on all this math lol but I put the clamp after my "look at" player, but it isnt stopping the rotation, the cam rotates 360 still :/
Screenshot of my settings:

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14500
  • Official Playmaker Support
    • View Profile
Re: Limit Look at Rotation
« Reply #18 on: March 30, 2018, 12:49:25 AM »
Hi.

 does it work with the simple Look at action?

Bye,

 Jean

18LSC

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Re: Limit Look at Rotation
« Reply #19 on: March 30, 2018, 06:00:56 PM »
Hi.

 does it work with the simple Look at action?

Bye,

 Jean

I also tried it with 'Look at' in the same layout as you see, also didnt work :/

[update]
okay I tested a little more, some settings do actually work and it stopped it rotating, but after a certain number it will not work, confusing, I tried 0 - 160 degrees, it will stop at 160, but if i keep moving to the point of -160 (which only happens in game), it starts moving again :|

at some point of the objects rotation it goes into negative numbers, am I missing a step that converts the objects rotation to a full 360 degrees? why am I getting negative numbers?

heres a quick vid of what is happening, watch the Y axis in the top right, it will stop at 160, then it goes into negative numbers and moves again
« Last Edit: March 30, 2018, 07:47:37 PM by 18LSC »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14500
  • Official Playmaker Support
    • View Profile
Re: Limit Look at Rotation
« Reply #20 on: April 01, 2018, 11:37:52 PM »
Hi,

 that's because the constraint system check the angle between the desirable target and the min and max, so if it gets contraint from the max value and all of a sudden the desirable angle falls into a minimal constraint, than it jumps to the minimal value. That's what you see here.

 Try first with a -30 30 constraint and make your target rotate around the camera to understand the principle.

not sure there is a way out. how would you see the constraint transform behave when it jumps from max to min or min to max?

Bye,

 Jean

 Bye,

 Jean

18LSC

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Re: Limit Look at Rotation
« Reply #21 on: April 02, 2018, 04:22:46 AM »
Hi,

 that's because the constraint system check the angle between the desirable target and the min and max, so if it gets contraint from the max value and all of a sudden the desirable angle falls into a minimal constraint, than it jumps to the minimal value. That's what you see here.

 Try first with a -30 30 constraint and make your target rotate around the camera to understand the principle.

not sure there is a way out. how would you see the constraint transform behave when it jumps from max to min or min to max?

Bye,

 Jean

 Bye,

 Jean

I tried -30 30 but I don't quite grasp the principle you're explaining sorry :/ not sure what you mean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14500
  • Official Playmaker Support
    • View Profile
Re: Limit Look at Rotation
« Reply #22 on: April 03, 2018, 12:04:11 AM »
Hi,

 here's a screencast:



so you see that at the back, the min and max constraint swaps based on which side the target is.

Does that make more sense?

 Bye,

 Jean

18LSC

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Re: Limit Look at Rotation
« Reply #23 on: April 03, 2018, 04:52:07 PM »
Hi,

 here's a screencast:



so you see that at the back, the min and max constraint swaps based on which side the target is.

Does that make more sense?

 Bye,

 Jean

Yeah thats the same thing that happened on my testing, so this is unavoidable?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14500
  • Official Playmaker Support
    • View Profile
Re: Limit Look at Rotation
« Reply #24 on: April 03, 2018, 10:46:52 PM »
Hi,

The question would rather be how would you like the constraint system to work in this case? the only solution I can see is to not jump but animate back the gameobject to go all the way across the range and hit the min limit instead of jumping to that limit. For this an easy solution is to build a rig where you have a child Gameobject attached to the camera at several units in the looking direction, and then have the real camera smoothlooking at this target, then as the constraint makes it jump, the smooth look at will smoothly transition from one limit to the other.

I guess this is your desireable behaviour right? like the head of a human, it would not jump from right to left, but actually rotate smoothly but fast from one side to the other. Correct?

Bye,

 Jean

18LSC

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Re: Limit Look at Rotation
« Reply #25 on: April 04, 2018, 02:25:35 AM »
Hi,

The question would rather be how would you like the constraint system to work in this case? the only solution I can see is to not jump but animate back the gameobject to go all the way across the range and hit the min limit instead of jumping to that limit. For this an easy solution is to build a rig where you have a child Gameobject attached to the camera at several units in the looking direction, and then have the real camera smoothlooking at this target, then as the constraint makes it jump, the smooth look at will smoothly transition from one limit to the other.

I guess this is your desireable behaviour right? like the head of a human, it would not jump from right to left, but actually rotate smoothly but fast from one side to the other. Correct?

Bye,

 Jean

Yeah thats about right, id like it if the target object goes from one limit to the other behind the object, the rotation will then turn back towards the other limit, instead of doing that instant flip, like a head just like you said.

One method I made to work was to have a childed objects with smooth look at always following the player updating its rotation.
And using 2 states, with the main object (head, camera) looking at the player only during one state, and if the 2nd "look at" goes past a certain rotation, it triggers the 2nd state, which stop the head rotating past a certain point. Only reactivating the 1st state if the target object is within a certain range of rotation again. Using float compare for the state transitions.
I just worry how performance costly this method is if I start duplicating multiple prefabs around.

I'm not quite sure how your described method works in comparison to mine, sounds kind of similar though.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14500
  • Official Playmaker Support
    • View Profile
Re: Limit Look at Rotation
« Reply #26 on: April 05, 2018, 12:01:35 AM »
Hi,

 here it is:



if you want the scene, let me know, but it's pretty straight forward.

 in terms of performances, you'll be fine really, how much of these do you think you are going to have in your scene?

 Bye,

 Jean

18LSC

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Re: Limit Look at Rotation
« Reply #27 on: April 05, 2018, 11:38:10 PM »
Hi,

 here it is:



if you want the scene, let me know, but it's pretty straight forward.

 in terms of performances, you'll be fine really, how much of these do you think you are going to have in your scene?

 Bye,

 Jean

Yeah I guess id have to take a look at the scene to understand how it works a bit better thatd be great :) thanks for all the work! :D

And Id probably have like 8-12 of them at most.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14500
  • Official Playmaker Support
    • View Profile
Re: Limit Look at Rotation
« Reply #28 on: April 09, 2018, 10:53:42 PM »
Hi,

 here we go, please find it attached. Move the cube around in your scene view to check out the behaviour.

A dozen of these will be totally fine in your game.

Bye,

 Jean

18LSC

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Re: Limit Look at Rotation
« Reply #29 on: April 10, 2018, 09:30:17 AM »
Hi,

 here we go, please find it attached. Move the cube around in your scene view to check out the behaviour.

A dozen of these will be totally fine in your game.

Bye,

 Jean

Thanks a lot, I tested it, it really helped me to understand your rig now.