playMaker

Author Topic: Math problem [SOLVED]  (Read 1617 times)

Grendal

  • Playmaker Newbie
  • *
  • Posts: 31
Math problem [SOLVED]
« on: September 28, 2015, 04:29:26 AM »
I am using a hit-bar made from an elongated cube primitive over my enemy.

My problem is this: Unity 3d objects only have a scale value and so you can't simply set length to 100 to match your hitpoints and reduce by variable subtract like you can in 2d. So I set my scale to 1 which looks about right and reduce it in float increments to 0.0 and it works great. However, my damage and hitpoints are still based on 100s system 0-100. I can't seem to wrap my math-poor brain around how to convert say 57 incoming damage into .057 float value using Playmaker actions.
« Last Edit: September 28, 2015, 04:12:00 PM by Grendal »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Math problem
« Reply #1 on: September 28, 2015, 04:40:56 AM »
Hi,

 for this, you can use floatRemap action, you can find it on the Ecosystem.

so you have a scale from 0 to 100 and you can remap that to range from 0 to 1 if you want. and so 57 will become 0.57

in your case, simply dividing by 100 would work too.

Bye,

 Jean

Grendal

  • Playmaker Newbie
  • *
  • Posts: 31
Re: Math problem
« Reply #2 on: September 28, 2015, 07:13:33 AM »
It works when I divide by 1000  (ie. 37/1000 = .037).
The issue with this is it creates a negative value in debug view.. not sure why since it works fine on my calculator.



EDIT:
Ok.. I must have been really tired last night. Got up today and figured it out pretty quick. It was 100.. duh and I was way over thinking my process. I was trying to subtract my damage value from my scale and then scaling.. when all I needed to do was grab the damage value and divide its value by 100 and then simply display as the new scale... /shrug
It works as intended now!
« Last Edit: September 28, 2015, 04:15:35 PM by Grendal »