Jump to content

Forces on Controllers


Rick
 Share

Recommended Posts

Everything I have read and tested we can't apply forces on controllers since version 2.20. I need to do knock backs on controllers. Currently I'm hacking around this by applying the force to a body box and then using PositionEntity() on the controller to the body box position (tried a fixed joint between them, but that didn't work either). This method I'm using is kind of hacky and not ideal.

Link to comment
Share on other sites

That might be possible. You would have to make it jump also. The down side to that is you have to manage that over multiple frames. If it worked like other forces we can just make 1 function call to apply the force and be done with it. Having to do it over multiple frames could make the code more cumbersome to work with.

 

Let's say I want to do this knock back to a controller. I would need to set the controllers rotation to the direction I want it to go, then supply a jump value to get it in the air and a move value to start it moving. Then I have to change the move value being passed to UpdateController() at some given point in time.

 

Or we could just use ApplyForce() on the controller and not have to worry about it anymore. I just think this would be easier.

 

What I did to get around this was to create a cone body and apply my force to that, then just set the controllers position to the cones position until the velocity of the cone was all 0's. The downside to that is that the controller doesn't register collisions when PositionEntity() is used on it, but in my example it doesn't matter as it's following the collisions of the cone, and it doesn't need to worry about bullets or anything while it's in the air.

 

I think your way would work also, but managing the move value or multiple frames might prove tricky depending on your code setup.

Link to comment
Share on other sites

  • 2 weeks later...

I created a class that inherits the controller, thus am able to store data / properties per NPC. This allows for single frame events to be fired. With the movement at a high value for one frame, (and even a jump) the NPC can look like it's knocked back abruptly when damaged.

 

I think your method of creating a temporary body, applying force, then setting the global position should work just fine.

 

another idea would be getting a vector3 behind the controller, and using a Curve() math function on it.

 

Just some ideas :blink:

Link to comment
Share on other sites

I think your method of creating a temporary body, applying force, then setting the global position should work just fine.

 

another idea would be getting a vector3 behind the controller, and using a Curve() math function on it.

 

The other body method works pretty well.

 

The problem with using the Curve method is that you would still be setting the position which would kill the physics.

Link to comment
Share on other sites

I think you could place a physics cloak over the player, so when the player moves, it will move with him, and when applying force the the cloak, it will move the player too.

 

The cloak could look like a flat cylinder on top of the controller, and few flat cubes hanging on all sides of the player. The cloak parts are connected with fixed joints, but the whole cloak is not connected to the player controller, it's just laying on on him.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...