playMaker

Author Topic: Translate Per Second [SOLVED]  (Read 7249 times)

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Translate Per Second [SOLVED]
« on: May 19, 2014, 03:34:44 AM »
Hi,

Im using translate to make the player move in (Self) space (Z Axis) and im using the FixedUpdate, PerSecond and Every Frame enabled.

However, i wanted the translation to happen slower. I have come to realise that i cant change this in Playmaker as there is no option to under Translate Action.

Other topics have advised to use TransformDirection. I have know idea how to use this. Is this something i should use to achieve what im after? https://hutonggames.fogbugz.com/default.asp?W477

Thanks

Nick
« Last Edit: June 03, 2014, 09:44:45 AM by coxy17 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Translate Per Second
« Reply #1 on: May 20, 2014, 01:46:27 PM »
Hi,

 Slower only means you should lower the z value, instead of 10 put 5 and it will go twice as slow.

 
 Bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Translate Per Second
« Reply #2 on: May 21, 2014, 04:30:49 AM »
Hi Jean,

Sorry just realised i wasn't specific enough in my first post. I understand that reducing the number will make it slower. However, i want the player to reach an X distance over time. e.g. 10 (equivalent in World space). its a 3D game btw

Im using Translate to make my character walk. I think Vector3.Lerp is along the lines of what im after but dont think i can achieve the same type of movement as the Translate action does with this, as Lerp starts of with an ease and finishes with an ease.

Behavior:
If the player is still holding forward it will keep going another 10 etc. If the player lets go of forward it will finish the last translation to the last X distance.

e.g. player presses key and player moves 10 over 3 sec. IF the player lets go before 3 sec is up then the player finishes its movement before stopping.

Ive drawn a diagram to visually show what im after

hope it helps :)

Nick
« Last Edit: May 21, 2014, 05:10:15 AM by coxy17 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Translate Per Second
« Reply #3 on: May 21, 2014, 06:43:11 AM »
Hi,

 ok, for this you'll need to use a tweening engine, where you can define an absolute target to reach within a define duration.

 Have you tried this?

Else, you can compute yourselve the actual values to inject in this translate action:

the equation to get the translation amount per seconds when you know the total distance and duration is a simple mathematical cross product:


total translation -> total duration
delta translation -> 1 second

delta translation = (1*total translation)/total duration

Does that make sense?

Bye,

 Jean




coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Translate Per Second
« Reply #4 on: May 21, 2014, 08:27:39 AM »
Hi, it sort of makes sense. Ive not looked into tweening yet.

I'll take a look at both of your suggestions.

I'm using physics to control my character so would tweening affect this? I have my player walking up walls etc

Thanks again

Nick

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Translate Per Second
« Reply #5 on: May 21, 2014, 08:42:52 AM »
It's best not to mix physics and forced translation. You can pass doing it for some things but since the position updates will change the position of the object its going to fight the physics inputs the entire time and usually gives unexpected results.

Possibly you might look into something along the lines of using a tween on a vector then injecting that into an Add Force action. Basically the idea being do the math on the vectors you want in the background but push them through the physics actions so the two systems aren't fighting.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Translate Per Second
« Reply #6 on: May 21, 2014, 10:33:40 AM »
Hi

Lane
Im sort of understand what you mean, but im new to this area so i would need to research in order to get a working example.

Jean
Quote
total translation -> total duration
delta translation -> 1 second

delta translation = (1*total translation)/total duration

Does that make sense?

How can i achieve this in playmaker? what states would i need. So i can experiment? or would i have to create my own script?

thanks

Nick

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Translate Per Second
« Reply #7 on: May 22, 2014, 10:06:05 AM »
Hi,

Ive tried looking into Delta Time and i am struggling with how to construct it in playmaker

Would i need the following? would i need to store DeltaTime and put into Translate action?
  • Translate Action
  • Get Time Info (Delta Time)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Translate Per Second
« Reply #8 on: May 23, 2014, 12:52:53 AM »
Hi,

 you don't need the delta since the check box "per seconds" is doing that for you in the background.

 Allow me few days ( bump sometime next week) and I'll do a micro sample shoing this.

Don't overthink this tho, it's a division of the total distance by the duration, and you inject that into the translate value, that's all there is to it really.

Bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Translate Per Second
« Reply #9 on: May 23, 2014, 03:11:38 AM »
Hi Jean,

Oh ok. I would really appreciate you offering to create a micro sample. Really getting into this and i work better with demos.

I will bump next week

Thankyou

Nick

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Translate Per Second
« Reply #10 on: May 28, 2014, 03:05:28 AM »
bump

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Translate Per Second
« Reply #11 on: May 29, 2014, 01:45:30 AM »
Hi,

 ok, here we go, download this micro sample

It's simple enough to understand what's going on. We compute first the translation value, and then we translate using that value and exit the state with a timer so that we translate during the right amount of time.

 I still encourage you to use proper tweening engines as they will give you more flexibity.

Bye,

 Jean



coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Translate Per Second
« Reply #12 on: May 29, 2014, 02:37:26 AM »
Hi, thanks I'll take a look :)

If I use tweening engines then won't this conflict with physics? I have gravity switches etc.

Nick

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Translate Per Second
« Reply #13 on: May 29, 2014, 02:42:31 AM »
Hi,

 Translate will conflict just as much as itween would.

 For physics, you should use "forces" to move objects around.

 Bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Translate Per Second
« Reply #14 on: May 29, 2014, 09:36:33 AM »
Hi Jean,

The example is great and i understand now what you have done

However, i noticed that the distance in player has moved is always slightly off a round number and is never the same number. e.g. moving from 0 > 10 on Z sometimes finishes on 10.0301 or 10.00004 etc. Why is this?

Is this due to the 'Wait' action not kicking in at the same time during runtime?

i need this exact to the round number e.g. 10 as when the player moves again it starts to increase the value further away from the values im after.

what im after e.g.
0 > 10 > 20

what im getting
0 > 10.0201 > 20.1200

Thanks

Nick