playMaker

Author Topic: "Smooth Look At Direction" with FixedUpdate?  (Read 200 times)

Hasuman

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
"Smooth Look At Direction" with FixedUpdate?
« on: May 14, 2019, 12:04:27 PM »
Hi, first time poster, long time lurker here!

I'm currently working on a third person character controller system that uses rigidbody for movement. I ran into an issue where my rigidbody starts jittering really badly if I have Smooth Look At Direction in the same state that handles Add Force stuff for movement. Tried getting alternatives for this from the Ecosystem, but none of them helped with this issue. I heard that if an action is set into FixedUpdate it wouldn't cause jittering since it's designed for physics mainly. I can't find any alternatives that come with this option though. I'm also trying to avoid using Torque for rotating the character since I want movement to be as snappy and accurate as possible, while still preserving the physic engine's smoothness and freedom of movement.

Of course, one way I could fix this would be by rotating the character model instead of the rigidbody, but that would make directional forces, raycasting etc. so much more complicated to handle, and I would prefer to keep things as simple as possible at this point in development.

MajorIdea

  • Full Member
  • ***
  • Posts: 131
    • View Profile
Re: "Smooth Look At Direction" with FixedUpdate?
« Reply #1 on: May 15, 2019, 10:12:28 AM »
I'd love such an action but I'm not sure if it would work well. Seems like you'd still be mixing physics with transform and that's usually a no no.

Not sure if this will work for you but what I usually do is use a Transform.Point of 0,0,0.5 for example (a point just ahead of the player) and use that vector in the "At Position" field in AddForce. This basically makes the player face in the movement direction. Adjust the Angular Drag in the rigidbody component to try and make it as snappy as you can.

Hope that helps.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4379
    • View Profile
    • jinxtergames
Re: "Smooth Look At Direction" with FixedUpdate?
« Reply #2 on: May 16, 2019, 04:54:11 AM »
Hi.
You should probably separate the "Smooth Look At Direction" to another fsm.
FOR HIRE:Playmaker/C#

Playmaker Samples <-------------> Easy Exporter <---------------------> TPA Actions

Hasuman

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: "Smooth Look At Direction" with FixedUpdate?
« Reply #3 on: May 16, 2019, 01:52:00 PM »
That's a good idea. Maybe I'm too focused on keeping things simple that I kinda didn't want to make a seperate FSM just for that.

Also, I did sort of fix the problem by going into the action's script and just switched Update to FixedUpdate. Can't see any jittering anymore. So far so good, but I'm expecting it to break somehow some day.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4379
    • View Profile
    • jinxtergames
Re: "Smooth Look At Direction" with FixedUpdate?
« Reply #4 on: May 16, 2019, 02:30:40 PM »
Hi.
Its a good thing to use many fsm's.

I it also good to read this wiki page :
https://hutonggames.fogbugz.com/default.asp?W1462
FOR HIRE:Playmaker/C#

Playmaker Samples <-------------> Easy Exporter <---------------------> TPA Actions