Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: stitchlips on October 01, 2016, 10:51:09 AM
-
I think I have gotten close to doing this but I am still missing something. I have an AI controller NPC that is fully rigged and loaded with animations. The animations are simply triggered in mecanim by movement. If horizontal is greater than one, then the animation for forward movement plays. If it is less than zero, then the animation for backwards movement plays. The same idea works for left and right as well.
Using PLaymaker, how could I determine when my NPC moves and then feed that movement into the mecanim animator. These movements are all mecanim floats. I can set animator float with a value and it works. What I would like to do is this.
When NPC moves this way, get movement and set NPC float accordingly. Any idea?
-
Hi,
if you are using axis for the movement you can use the 'get axis' value and then use 'set animator float' to set the float in the animator,
set both to every frame
-
It's an NPC controlled by ai. I was under the impression that get axis was for things such as joysticks so I didn't think I could use that action for what I needed.
-
Hi,
sorry i did not read the question well,
What you can do is get the position, save in a float for x,y,z separately (call it old x / y / z for example)
Then do a next frame action.
Then do a get position again (call it new x / y / z for example) and compare the floats with 'float compare' for each direction (x / y / z ) needed.
this way you can know which way the npc is going
after all directions compared loop back to the 1st state.
if (for example) old x is less than new x, set animator float x to -1
-
Now that is genius! Will give it a try. Thanks!
-
Hi,
sorry i did not read the question well,
What you can do is get the position, save in a float for x,y,z separately (call it old x / y / z for example)
Then do a next frame action.
Then do a get position again (call it new x / y / z for example) and compare the floats with 'float compare' for each direction (x / y / z ) needed.
this way you can know which way the npc is going
after all directions compared loop back to the 1st state.
if (for example) old x is less than new x, set animator float x to -1
That works. The only problem I was running into was that the float compare was so precise that it wasn't always seeing a difference in the positions. This could also be because my NPC is slow. I added a "buffer" state with a wait of .05 to give the positions time to change and now when the NPC moves, the animations trigger. When the NPC stops, it triggers the idle animation state. Thanks!
-
Hi,
I am happy you got it to work :)