playMaker

Author Topic: How to set a double variable in a playmaker action?[SOLVED]  (Read 3836 times)

kiko

  • Playmaker Newbie
  • *
  • Posts: 17
How to set a double variable in a playmaker action?[SOLVED]
« on: February 22, 2014, 12:38:03 PM »
Hi, I need to set Unity DSPtime value within a playmaker script, and it's a double, not a float.

Basically I'm looking for a "fsmDouble" type variable. Does anything like that exist? If not, is there some other way to make an action define a double variable?

Thank you!
« Last Edit: February 24, 2014, 01:17:00 PM by jeanfabre »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: How to set a double variable in a playmaker action?
« Reply #1 on: February 22, 2014, 02:34:16 PM »
I didn't know what a double was, and i couldn't seem to find it in the Unity docs, but its used in some audio script examples so its some sort of numerical value not based on Time.time?

Can you use .Value to transfer the number in the double? Usually thats what you do to convert between internal FsmWhatever's to regular variables when making Actions for PM.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

kiko

  • Playmaker Newbie
  • *
  • Posts: 17
Re: How to set a double variable in a playmaker action?
« Reply #2 on: February 22, 2014, 08:23:12 PM »
thanks for you help, Lane.

Right you are :) Double is used for DSPTime, whereas time.time uses float.

Double is twice as precise as a float, and although you can convert, but it's not usually a good idea due to rounding errors.

So yeah, need to be able to define a double directly in an action without rounding it off.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to set a double variable in a playmaker action?
« Reply #3 on: February 24, 2014, 09:11:25 AM »
Hi,

 tricky... Do you actually need that precision for sure? or the sdk you are using is using it, but actually it would work fine if it was parsed back to a regular float?

Can you tell us more about your use case?

http://forum.unity3d.com/threads/184300-Time-deltaTime-amp-Audio-Play-or-AudioSettings-dspTime-amp-Audio-PlayScheduled

I think you can get away with parsing it as a float.

bye,

 Jean

kiko

  • Playmaker Newbie
  • *
  • Posts: 17
Re: How to set a double variable in a playmaker action?
« Reply #4 on: February 24, 2014, 01:08:35 PM »
Thank you for the help, Jean.

I'm trying to reverse engineer this script that you made:
http://hutonggames.com/playmakerforum/index.php?topic=2194.0

...but I need it to work with AudioController.PlayScheduled method instead:

public static AudioObject PlayScheduled(
   string audioID,
   double dspTime,
   Vector3 worldPosition,
   Transform parentObj,
   float volume,
   float startTime
)

Now that I think of it, I don't actually need to define that dspTime value directly, as I am going pull that value directly from another script at runtime.
« Last Edit: February 24, 2014, 01:13:59 PM by kiko »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to set a double variable in a playmaker action?
« Reply #5 on: February 24, 2014, 01:12:51 PM »
hi,

 Use this to convert from float to double. that will be just fine.

http://stackoverflow.com/questions/5986980/convert-float-to-double-loses-precision-but-not-via-tostring

Bye,

 Jean

kiko

  • Playmaker Newbie
  • *
  • Posts: 17
Re: How to set a double variable in a playmaker action?
« Reply #6 on: February 24, 2014, 01:14:54 PM »
Thank you Jean! You're lifesaver :)