Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Ulrick on August 08, 2018, 12:57:53 AM
-
Hello,
My problem is probably super simple but I can't find the solution:
I have an old school dungeon crawler system: 1st Person square by square movement. (Grimrock, Dungeon Master, etc.)
The movement is simple: When you press a key, you move by 1 unit in that direction (every square is a 1 unit square, handy !)
I'm using a simple translate (no need for a character controller or full 360 physics movement here), but my translations are instant.
How could I have a slow and smooth translation from one square to another.
(like 1 second for example, with speed increase / decrease with a curve, between each square) ?
Thanks a lot ! I'm stupidly blocking on something that looks easy...
-
hi.
Get the current position, then use a operator to add a value for the new position and store in another variable (call it 'new position' for example)
Then for now you could use a float/vector2/vector3 interpolate action (There will be native tween actions with more options included in one of the next PlayMaker updates) and set the mode to ease in out and place the current position and the new position in it.
You can set the time to your needs.
Also set an event for when the action is Finished.
Store in a variable (call it 'Moving' for example)
Then use a 'set position' and turn on 'Every Frame' and place the 'Moving' variable.
In the next state do another 'set position' with 'Evety Frame' disabled and place the 'new position' variable.
This is just to be sure that the final position is correct.
-
Use the tween actions for that. You have durations and curves.
-
Hi guys !
Thanks for your feedback :)
I don't have de Tween options, even installing iTween ?
Do I need to reinstall Playmaker after ?
Anyway, I tried djaydino's method, and it works... almost ! :D
It move, with an ease and all...
But it moves in world position. In Local my Z is always the front of the player but it always goes in the World Z... even if I choose self for any of the actions (Set Position and Get Position... kinda weird)
Thanks already !
-
Hi.
Do you have 'Get Position' and 'Set Position' both set to 'space : self'
Its best not to use iTween as it is outdated and slow.
the new native tween action are coming soon :)
-
Yes for the Get and the Set, I join a screenshot of the action stack if you want to check, thanks for your time !
-
(I tried with a Vector3 but the result is far worst :D haha)
-
Hello, me again :D
I tried with a Translate, apparently it keeps the Self/Local coordinates, but don't behave correctly (I can't have it move the right amount of unit in the right amount of time)
So it's the Set Position which can't move it in the Local coordinates even if Self is checked... Is this normal ?
-
Hi.
I can see an issue in your image.
You are using 'float add' to the 'new_position_z' variable. this variable will always be 0 to start unless you feed it the current position.
instead you need to use a 'Float operator' and place the 'current_position_z' in float 1, then set '1' in float 2.
Set Operation to 'Add'
and place 'new_position_z' in "Store Result"
-
Hi djaydino !
Thank you for your help !
Problem is that it still does the exact same thing than my actions:
It works but move my player in the world space (which seems logical, saying like that), but not regarding it's local orientation.
So no matter my player orientation, he will always translate in the positive Z axis of the world space, not its local Z axis...
While waiting for help, I tried another brand new system from scratch, with translations.
It works BUT...
The precision is not fully accurate (I always arrive with positions like: 1,0XXX instead of 1) and of course the lack of precision is bigger and bigger the more I move...
So I tried what you said: Getting the position before then adding 1 in a Set position at the end, to correct the precision: And so same result as before... the Set Position adds 1 in the World Space, no matter my Local Rotation.
I have the feeling than Get and Set Position in Self Space is not working (or still working as World), OR I did not understand how to use them. :-\
I hope being clear with my long explanation,
Thank you for your time :)
-
If you want to check, here is the new system in screenshot.
Btw: You can notice another problem: When I translate, the value I need to add must by 4 times bigger than what I want (that's why I put 4 in New_Z)
I cannot understand why ?
Same for my angles: if I want a 90 degrees rotation, I need to add 360 in a float...
But well... each problem at a time ;D
-
Use itween actions.
It has one action to do exactly the same you want.
-
I don't have the Tweens action in my Playmaker, and apparently it's currently deprecated anyway :-/
-
Hi.
Playmaker Native tween action are coming soon :)
But usually when i use interpolate actions i use a set position in the next state to be sure to have the correct position.
So in your case make a state after the interpolate and use 'set position' with the "new_z" variable
the sizeof the new position depends on your field size/pixels per unit etc you might want to resize things. also scaled items are best set in a parent with a scale of 1
-
Hello !
Yup I see for the final Set Position and your solution for the final precision works, thank you !
But the Local / World problem is still the same.
I join a screenshot if my explanation were not clear with the FSMs:
I want to go in the Local Z direction when I press Up / W (in green)
and it goes in the World Z direction, even with "Self" selected in the Get / Set positions (in red)
It seems super simple tho...
-
Hi.
if you rotate the movement will stay the same, unless if inside a parent that is rotated.
But using a parent in this case will not be good either.
If the rotation is in steps of 90 degree you can make a system to determine on what rotation you currently are.
I made a sample scene (attachment below) that you can check as it is hard to explain with text :)
just place in your project or a new project that has playmaker installed.
Let me know if you understand what i am doing there, if not i will see if i can make a video next week.
-
It works perfectly !
I understand for the rotation, it seems clear :)
I just add my block-by-walls system on top of it and it works,
Thanks a lot for your time ! I'll show you the result :)
-
Hi.
Happy to help :D