playMaker

Author Topic: [SOLVED] HELP: choppy movement set velocity in playmaker  (Read 4768 times)

ryf9059

  • Full Member
  • ***
  • Posts: 100
[SOLVED] HELP: choppy movement set velocity in playmaker
« on: June 12, 2013, 12:23:00 AM »
Hey,

This might not have too much to do with playmaker itself (but I'm not sure about this, it uses FSM) but I can't find the answer anywhere else and I thought you guys are very experienced experts maybe wouldn't mind helpming me there out so I will post it here anyways.

Basically. I have a cube that can be controled by keyboard using translate, and there is a FSM attached to the cube which spawns a bullet upon clicking 'x' key. The bullet is a prefab that has a FSM attached to it which sets the velocity upon activation.

The cube and the bullet are moving by different method but their displacement speed is the same so if I spawn the bullet and move the cube they should appear to be still relative to each other, but the fact is that the bullet appears jumpy and is kinda bouncing left and right somehow. And this is where I don't understand.

I have test this on several computer and they all have the same issue, I think this may have something to do with physics not being updated in the same frame as the cube but I didn't do anything other than setting the speed so I have no control over it.

I have made a zip file for the executable with a readme file in it, you can try to run it see if you are having the same result.

[LINK REMOVED]

If you do see the bouncing, here is the link to the actual minimal project that I made if you guys don't mind taking a look

[LINK REMOVED]


This problem have been stucking me for weeks, help will really be appreciated.
Thanks!
« Last Edit: June 17, 2013, 04:52:46 AM by ryf9059 »

ryf9059

  • Full Member
  • ***
  • Posts: 100
Re: HELP: choppy movement set velocity in playmaker
« Reply #1 on: June 13, 2013, 09:57:55 PM »
Bump for attention.

I have let few more people tested it and they said this has something to do with setting the speed every frame, but I didn't. Really don't know why

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: HELP: choppy movement set velocity in playmaker
« Reply #2 on: June 14, 2013, 01:56:59 AM »
Hi,

 You need to follow the physics object using the "fixed" update call, that's likely your issue.

Let me take a look.

bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: HELP: choppy movement set velocity in playmaker
« Reply #3 on: June 14, 2013, 02:00:20 AM »
Hi,

 I removed the links, you are not allowed to distribute PlayMaker, it's up to everyone to get it from the asset store, so when you share a project, take out the playmaker folder.

 thanks :)

bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: HELP: choppy movement set velocity in playmaker
« Reply #4 on: June 14, 2013, 02:07:41 AM »
Hi,

your problem is what I though and do not lie in playmaker actually. it's in your test.cs script.

 basically, you animate your physics cube "onUpdate", and because the camera is attached to the cube, the bullet becomes choppy because the bullet is physics drive, and so when the camera refresh its position is never can have a true idea of where the bullet is because it's only available "onFixedUpdate",

so modify your text script and simple use "FixedUpdate" instead of "update" and all will be very smooth :)

bye,

 Jean

ryf9059

  • Full Member
  • ***
  • Posts: 100
Re: HELP: choppy movement set velocity in playmaker
« Reply #5 on: June 16, 2013, 01:03:33 AM »
your problem is what I though and do not lie in playmaker actually. it's in your test.cs script.

basically, you animate your physics cube "onUpdate", and because the camera is attached to the cube, the bullet becomes choppy because the bullet is physics drive, and so when the camera refresh its position is never can have a true idea of where the bullet is because it's only available "onFixedUpdate",

so modify your text script and simple use "FixedUpdate" instead of "update" and all will be very smooth :)

Thanks for the reply!

It worked for me. But what I don't understand is that I already used deltaTime in my update, should that automatically smooth things out? Also if in fixed update I'm not supposed to use deltaTime anymore right? Because it's already called in the fixed time intervals.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: HELP: choppy movement set velocity in playmaker
« Reply #6 on: June 17, 2013, 01:28:44 AM »
Hi,

 Delta time is usefull in all types of frame updates. "Fixed" update should simply ring "Physics" in your mind, nothing more. You can not achieve smooth camera follow just with deltatime value, because the physics and the unity engine are separate, that's why FixedUpdate is needed. If I am correct, it's the point in the current frame where the physics was completly computed and all tranforms true to what the physics made up for that frame.

I can't really find a good example to desribe why delta time has nothing to do with this :) this is outside my current understanding of the inner behavior of Unity. Maybe you could ask this on UA or the Unity Forum? that's a very good question.

bye,

 Jean