playMaker

Author Topic: Set Velocity not working  (Read 949 times)

thunder

  • Playmaker Newbie
  • *
  • Posts: 22
Set Velocity not working
« on: May 20, 2022, 03:58:03 PM »
Im trying to limit the velocity of my player object using clamp and set velocity action, but the set velocity is not actually working. Any tips?

Twood

  • Junior Playmaker
  • **
  • Posts: 76
Re: Set Velocity not working
« Reply #1 on: May 20, 2022, 10:46:58 PM »
Only thing I can guess is are you using add force every frame? That could break it.

Get velo, vector 3 clamp, set velocity... that stuff is all fine to clamp the speed if there's no add force going on.

thunder

  • Playmaker Newbie
  • *
  • Posts: 22
Re: Set Velocity not working
« Reply #2 on: May 21, 2022, 10:46:23 AM »
I understand, and yes I have checked the "every frame" on my add force action because its a rigidbody controller so I need to add force every frame where the player is pressing WASD and then I limit the speed to a maximum speed allowed for the object. If Im breaking playmaker by using that combination then thats unnaceptable, because I can do the same thing using C# or Bolt and it works just fine.

Twood

  • Junior Playmaker
  • **
  • Posts: 76
Re: Set Velocity not working
« Reply #3 on: May 21, 2022, 03:03:55 PM »
At any rate if you wanted to do it all in PM you might just do it so you check the top speed and stop adding force when it's at top speed.

In this example my add force is 20 but the object never moves faster than 1 because that's where I limited it.






thunder

  • Playmaker Newbie
  • *
  • Posts: 22
Re: Set Velocity not working
« Reply #4 on: May 21, 2022, 05:53:52 PM »
Thank you, thats a good solution indeed, now I just wanted to understand why my actions didnt work, this is confusing because, as I said, it works fine outside of playmaker.

UPDATE: actually it will break after some add force (like 10000 per frame) in code, but still it will last longer to break in comparison to playmaker. Anyways I guess the solution is to not keep adding force and setting velocity together, as it is said in unity docs to not mess with velocity directly by "set velocity".
« Last Edit: May 22, 2022, 06:53:30 PM by thunder »

Twood

  • Junior Playmaker
  • **
  • Posts: 76
Re: Set Velocity not working
« Reply #5 on: May 23, 2022, 05:47:18 PM »
Yeah I have no clue why it works in some other circumstance, but in general fighting the physics engine every frame is thought to be a risky idea. If it does bug out that way, you're not going to be able to fix it, so it's easier just to use different ideas.