playMaker

Author Topic: how to add force with FixedUpdate?[SOLVED]  (Read 3776 times)

Mulbin

  • Junior Playmaker
  • **
  • Posts: 90
how to add force with FixedUpdate?[SOLVED]
« on: June 15, 2016, 05:16:00 PM »
Is this possible with playmaker? I really need to add thrust to an object and know that the result will be more or less the same regardless of the framerate/speed of the computer running it.  I don't see any way to select the update type on the Add Force component.
« Last Edit: June 27, 2016, 03:52:39 AM by jeanfabre »

ergin

  • Junior Playmaker
  • **
  • Posts: 86
Re: how to add force with FixedUpdate?
« Reply #1 on: June 15, 2016, 09:07:42 PM »
- From project view type Add Force
- Double Click on Add Force (C#)
- Source will display at Line 71 there is OnFixedUpdate
- Change it to OnUpdate or OnLateUpdate.
- File / Save then Build / Build All

but problem here is that rigidbody operations has to take place in fixed update or there will be flicker in the motion.

Quote
FixedUpdate should be used instead of Update when dealing with Rigidbody. For example when adding a force to a rigidbody, you have to apply the force every fixed frame inside FixedUpdate instead of every frame inside Update.

https://docs.unity3d.com/ScriptReference/MonoBehaviour.FixedUpdate.html
https://unity3d.com/learn/tutorials/topics/scripting/update-and-fixedupdate

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: how to add force with FixedUpdate?
« Reply #2 on: June 16, 2016, 03:16:15 AM »
Hi,

 I am stepping in because editing official Actions is a very bad idea, everytime you'll update PlayMaker, your changes will be lost and you'll have a buggy project...


AddForce must only be set in FixedUpdate.

If you have a case where you think it has to be done on lateupdate, I would be interested to hear more about it.

 If you MUST edit an official action, make sure you duplicate it, rename it like "AddForceLateUpdate" or something, and use that one, and then you'll be totally safe.

Bye,

 Jean

ergin

  • Junior Playmaker
  • **
  • Posts: 86
Re: how to add force with FixedUpdate?
« Reply #3 on: June 16, 2016, 10:06:09 AM »
Hi jean, thanks for the info...

Actually you are too right, I modified so many of actions it really becomes a problem when updating... I began using custom action wizard anywhere possible (which is a great feature for beginners as well)

By the way he has to change the public class name too or it won't build.
public class AddForceLateUpdate

Thanks again.

Edit: spelling and added last paragraph.
« Last Edit: June 16, 2016, 11:02:22 AM by ergin »

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: how to add force with FixedUpdate?
« Reply #4 on: June 16, 2016, 11:50:00 AM »
you should also read this : http://forum.unity3d.com/threads/fixedupdate-fixed-framerate-frame-physics-step.250080/

BTW did the gravity action work? you like?

Mulbin

  • Junior Playmaker
  • **
  • Posts: 90
Re: how to add force with FixedUpdate?
« Reply #5 on: June 17, 2016, 04:17:44 PM »
Guys... I want Fixed Update (not late) so it sounds like it actually already works the way I want :)

Haven't tried the gravity yet!  Will be experimenting over the weekend.