playMaker

Author Topic: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]  (Read 4714 times)

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
« on: September 27, 2018, 12:07:27 AM »
As per title  :o
« Last Edit: October 01, 2018, 03:04:59 AM by jeanfabre »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Shouldn't ADD TORQUE have an otiopn PER SECOND?
« Reply #1 on: September 27, 2018, 12:55:38 AM »
Hi.
Not that i know of, can't find anything using time.deltatime in unity forums/docs

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: Shouldn't ADD TORQUE have an otiopn PER SECOND?
« Reply #2 on: September 27, 2018, 03:50:45 AM »
Correct me if I'm wrong: for what I know, the PER SECOND option exists to make the action framerate independent.
Now, if this option is missing here, the torque I add each frame will be framerate dependent, and this inevitably gives framerate based results.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: Shouldn't ADD TORQUE have an otiopn PER SECOND?
« Reply #4 on: September 29, 2018, 02:06:08 AM »
Mhhh you mean that Playmaker actions only add PER SECOND option only if Unity features the option itself?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Shouldn't ADD TORQUE have an otiopn PER SECOND?
« Reply #5 on: September 29, 2018, 05:43:51 AM »
Hi.
No not really.

Force and Torque is done in OnFixedUpdate() in the actions.

Quote
FixedUpdate is named such because it's called a fixed number of times per second. By default the interval is every 0.02 seconds, or 50 times every second. You can change this (if you'd like) by going to the Time Manager, Edit -> Project Settings -> Time.

Which means it is already doing this per second :)

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: Shouldn't ADD TORQUE have an otiopn PER SECOND?
« Reply #6 on: September 29, 2018, 09:05:04 AM »
Perfect, thank you veeery much, dude :-)

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
« Reply #7 on: October 17, 2018, 01:04:32 PM »
Back here!
I sincerely don't know if this is coming from Unity or Playmaker, but I am now SURE that ADD TORQUE is NOT frame independent.
In fact, if I activate the VSync, and fix the framerate at 60 fps, the vehicle behaves one way, if I deactivate VSync, the game runs at around 120 fps, and the vehicle behaves completely differently.

I am absolutely sure that at the moment things are not working as expected for the ADD TORQUE command (or Playmaker action).

"Luckily", I plan to fix the framerate of my game at 60 with VSync (there won't be an option to set it differently, and the game won't run differently), so I shouldn't have any problem anyway, but still it would be nice to know what is really happening.
« Last Edit: October 17, 2018, 01:37:37 PM by megmaltese »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
« Reply #8 on: October 18, 2018, 02:00:00 AM »
Hi,

 Yes, Torque can be applied per seconds, it's just not available in the action, that's all.

 you can always do that manually, by multiplying your torque value by the deltatime, either manually or via the action PerSecond. So for any action that you want to turn into framerate independant, just use PerSecond prior.

anyway, I made an action for this on the Ecosystem: AddTorqueAdvanced.

Bye,

 Jean


PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
« Reply #9 on: October 18, 2018, 06:52:22 AM »
The AddTorqueAdvanced is a great idea, I was going to tell you that an Add Torque variable on the framerate doesn't make much sense, like ANY physics action that wouldn't be linked to time instead to framerate.
Honestly, I would cut away the old Add Torque and replace it with the new one, with just add the option to multiply with delta and that would be it.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
« Reply #10 on: October 18, 2018, 09:42:39 AM »
Hi,

 well, not really, because the best way when you want a constant rotation of a physic object is to set the velocity.

what are you trying to control? a wheel?

 Bye,

 Jean

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
« Reply #11 on: October 18, 2018, 10:06:45 AM »
Setting the velocity means sudden change to the object setting, but adding an acceleration means a more "faithful" change in the simulation.
Yes, I'm working on a vehicle simulation.
By using Add Torque, I don't need to deal with a lot of stuff, I only set up rightly the wheels parameters and all I have to do is to add the torque when the player accelerates or brakes.
If I'd set the velocity I'd need to use curves and extra data.
At least, this is what I know, it's the first time I'm doing this, sooo... easily I'm not doing the best thing possible.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
« Reply #12 on: October 19, 2018, 04:37:58 AM »
Hi,

 for wheels, I strongly recommend using a proper vehicle simulator engine.

controlling velocity also means making sure the ramping curves are realistic, so indeed if you control using velocity, you need some math to accelerate, decelerate, etc etc.

but, yeah, now you have a custom action for this.

 ideally, I think Playmaker should provide the everyframe with all the various options ( whicch update call, per seconds and in realtime or not), it would be great that this was built in, and not to be implemented on all actions)

 Bye,

 Jean

 

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
« Reply #13 on: October 19, 2018, 07:13:14 AM »
Trust me, if I could have used a simulation engine, I did.
The problem is that I HAVE to use cylinders as wheels and so there is literally NO ready solution in this direction.
I also think that at one point in development I will have to hire some specialist in physics to refine the simulation, because I'm not able to simulate the softness of the tire and the simulation simply breaks when going over 100 Kmh... but for now it's ok, the is working and fun even at lower speeds.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
« Reply #14 on: October 29, 2018, 04:58:02 AM »
Hi,

 uhm... what is the vehicle you are trying to simulate? One possible trick is to use different rig per speed and terrain, and you swith between them when necessary. so a regular wheel collider for high speed and a custom cylinder for low speed and bumpy terrain, etc.

Bye,

 Jean