playMaker

Author Topic: Reverse Float values?  (Read 2708 times)

derkoi

  • Full Member
  • ***
  • Posts: 187
Reverse Float values?
« on: July 16, 2012, 02:06:50 PM »
Hey,

I'm using a joystick to roll a ball object using torque, the joystick gives -1 to 1 values. The problem is that left on the joystick makes my ball roll right.

How can I get the -1 values to change to 1 and vice versa? Thanks

PlatinumPlayer

  • Playmaker Newbie
  • *
  • Posts: 26
Re: Reverse Float values?
« Reply #1 on: July 16, 2012, 05:55:58 PM »
Have you tried registering the joystick in the project input and used Get Axis Vector? For mouse wheel i simply used Get Axis with an axis name of "Mouse ScrollWheel", saved it as afloat, then did a logic test to see if that float was grater or less then 0. Positive meant scroll forward, negative meant scroll back.

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: Reverse Float values?
« Reply #2 on: July 16, 2012, 10:58:12 PM »
Sorry, should of said it's a mobile joystick. 

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: Reverse Float values?
« Reply #3 on: July 17, 2012, 04:48:25 AM »
Just to let people know, i edited the AddTorque.cs script & made a new one. AddTorqueReversed.cs

Changed this line:

Code: [Select]
if (!z.IsNone) torque.z = z.Value;
by adding a minus before the z.Value, like this:

Code: [Select]
if (!z.IsNone) torque.z = -z.Value;
It works fine now.  ;D