Playmaker Forum

PlayMaker News => General Discussion => Topic started by: megmaltese on September 26, 2018, 09:07:27 PM

Title: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
Post by: megmaltese on September 26, 2018, 09:07:27 PM
As per title  :o
Title: Re: Shouldn't ADD TORQUE have an otiopn PER SECOND?
Post by: djaydino on September 26, 2018, 09:55:38 PM
Hi.
Not that i know of, can't find anything using time.deltatime in unity forums/docs
Title: Re: Shouldn't ADD TORQUE have an otiopn PER SECOND?
Post by: megmaltese on September 27, 2018, 12: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.
Title: Re: Shouldn't ADD TORQUE have an otiopn PER SECOND?
Post by: djaydino on September 27, 2018, 02:49:19 AM
Hi.
Add torque work differently i guess, with velocity there :

https://docs.unity3d.com/ScriptReference/Rigidbody-velocity.html

https://docs.unity3d.com/ScriptReference/Rigidbody.AddTorque.html
Title: Re: Shouldn't ADD TORQUE have an otiopn PER SECOND?
Post by: megmaltese on September 28, 2018, 11:06:08 PM
Mhhh you mean that Playmaker actions only add PER SECOND option only if Unity features the option itself?
Title: Re: Shouldn't ADD TORQUE have an otiopn PER SECOND?
Post by: djaydino on September 29, 2018, 02: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 :)
Title: Re: Shouldn't ADD TORQUE have an otiopn PER SECOND?
Post by: megmaltese on September 29, 2018, 06:05:04 AM
Perfect, thank you veeery much, dude :-)
Title: Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
Post by: megmaltese on October 17, 2018, 10:04:32 AM
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.
Title: Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
Post by: jeanfabre on October 17, 2018, 11:00:00 PM
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

Title: Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
Post by: megmaltese on October 18, 2018, 03: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.
Title: Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
Post by: jeanfabre on October 18, 2018, 06: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
Title: Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
Post by: megmaltese on October 18, 2018, 07: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.
Title: Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
Post by: jeanfabre on October 19, 2018, 01: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

 
Title: Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
Post by: megmaltese on October 19, 2018, 04: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.
Title: Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
Post by: jeanfabre on October 29, 2018, 01: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
Title: Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
Post by: megmaltese on October 29, 2018, 09:58:50 AM
The race is offroad high speed, the vehicles are continuously running at high and low speed on offroad and road tracks.
I really can't detach from cylinder wheel. This solution would become tricky to maintain, I need something easy to update on all the vehicles.
Title: Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
Post by: jeanfabre on October 30, 2018, 02:39:05 AM
Hi,

 I would totally make a very thorough research on what's already available, because wheel physics is very complex indeed:

https://forum.unity.com/threads/wheel-controller-3d-customizable-three-dimensional-alternative-to-wheelcollider.441618/

I would contact each author you find that deals with advanced wheel collider, explain your case and check with them what's possible or not. And yes, for some advanced deals, an expert is likely the way to go for your core.


Bye,

 Jean
Title: Re: Shouldn't ADD TORQUE have an option PER SECOND?[SOLVED]
Post by: megmaltese on October 30, 2018, 03:31:53 AM
Thank you, I didn't know this, it may work for me.
Just checking if it can be applied to complex configuration vehicles, because my vehicles are a bit different from the standard "box+wheels" that are common vehicles.