Playmaker Forum
PlayMaker Feedback => Action Requests => Topic started by: foxdeltagames on August 01, 2014, 06: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.
-
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
-
I am bumping this post like you asked for :)
-
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.
-
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
-
Sounds awesome. It'll be perfect for my turret stuff. Think you can make a world/self space toggle?
-
bump
-
hmm, it seems this has been forgotten,
searched Ecosystem but no result....
sooo... ill just give it a Bump :)
-
Just giving it a little bump
-
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. :(
-
Hi,
Woah, seems to have miss that post over and over again :)
I'll have a look at this.
Bye,
Jean
-
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
-
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.
-
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?
-
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
-
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
-
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
-
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:
-
Hi.
does it work with the simple Look at action?
Bye,
Jean
-
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
-
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
-
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
-
Hi,
here's a screencast:
(https://i.imgur.com/FE389VG.gif)
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
-
Hi,
here's a screencast:
(https://i.imgur.com/FE389VG.gif)
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?
-
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
-
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.
-
Hi,
here it is:
(https://i.imgur.com/zOZOine.gif)
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
-
Hi,
here it is:
(https://i.imgur.com/zOZOine.gif)
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.
-
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
-
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.
-
Hello,
so I used your cool script and its working perfectly. But there is a problem. Maybe you mention here but is there any way how to reslove it?
Problem is that go over +/- 60 degree isnt working. Then Target goes behind Camera.. so Im not sure what to do it I need more angle :)
Here is a short video:
https://drive.google.com/open?id=1z04Wo9ymwIZjJ3O4tW4Ef3rJmn1GvIm7
-
Hi,
that's very odd. I can not reproduce this and I tried on 2018 and the latest playmaker.
can you try on a fresh project? is this happening still?
Bye,
Jean
-
Hi thanks for your reply.
For test I have this verions:
- Unity 2018.2.8f1
- Playmaker 1.9.0.p4 (but I reported it from version p6)
So I made new project, installed version of Playmaker above, open you scene and run it.
Still I have the same result. If I put there +/- 70, for example, rotation goes on back side too.
May I help you with something? ;)
[EDIT] I've tried with last p14 version and is still the same.
-
Hi,
ok, I could repro, indeed the clampRotation is not working properly in some cases.
Can you try this version of ClampRotation attached to this post?
If it works for you, I'll push that to the ecosystem.
Bye,
Jean
-
Hi Jean,
thanks for your work :)
So I tried and I have some results.
1) it seems that there is an issue in term of "ball going back", and this doesn't happend before. Value for rotation is -45 / 45.
https://drive.google.com/open?id=1EMIT8EAwcCT-5BftwLySPQKuPVjAPlRx
2) If I put, for example, -130 / 130 (imagine that I'd like to use this function for a tank turret) and maybe this plugin isn't for this usage...
https://drive.google.com/open?id=1Z1EiDtGU9tAygG6D0myPqWgai4l3UJuT
a) It seems that I can't go more then -90 (if 0 is on top, in term of video orientation) but +130 degree limit is working fine.
b) When I'm on back side of the "camera" and then see me again, the ball is going immediately with shorter way to my cube. But it's going on back side.
I think that this is really crazy example :) But because name of this function is Clamp Rotation (doesn't say anything that it could work only +/- 90 degree) I tested too.
-
Hi,
yes, 1) is a result of the new constraint routine used, because the technic is different, the behaviour is also not exactly the same. I noticed that, but I could not find a way around this.
2) have you tried to move the range so that it's within 0 and 180 so that the min is not a negative number? maybe it will go around this block.
It's a tricky thing, because the math behind this are complex ( for me at least, and I haven't found a definite rotation constraint that works for all cases yet).
If the solution is ok for your case right now, let's call it a day, let me progress on other things, and ping me in about a week or so and I'll have another go at the constraint action, I have another idea I'd like to experiment which would solve both issues at the same time ( where the jump between min and max would happens it crosses the virtual symmetry between min and max)
bye,
Jean
-
Ok thanks, Ill try what you wrote. Yes for now is enough.
Ill bump this post, as you said :) because to get this ClampRotaion funcionality will be amazing and with a lot of possible usages.
-
Hi Jean,
Im bumping this thread as you said, Im still interested :)
Martin
-
Hi,
Thanks for the bump :) I don't have time this week, I'll try next week.
Bye,
Jean
-
Hi Jean, im only bumping :)
And thanks for Playmaker its amazing!!! :)
-
bump, if there is something new:)
-
Hi,
it's in my todo, so I haven't forgotten about it, I need to find the right time, as it will require my full attention for this to work properly... with a full morning that I'll dedicated to this. I tried to hack around that few times already to no availability... that's one of these actions that needs proper math and transforms know how :)
Bye,
Jean
-
Hi,
Ok, managed to find some time to address this and I think I have the right clamping for you.
Now, it will swap clamp when it reaches the opposite side of the mid range, which is intuitivly what we want when we look at something yet clamped.
(https://i.imgur.com/ZO3ckXk.gif)
let me know how it goes for you.
Bye,
Jean
-
Hi,
sorry for my delay, now I've checked and looks nice ;)
Thanks a have a nice day
Martin