Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

Making Players Behave Like Normal Physics Objects

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Post Reply
ClockworkDice
Fighter
Fighter
Posts: 28
Joined: Wed Nov 02, 2016 12:59 am
Started SFD: Sometime in Pre-Alpha
Gender:

Making Players Behave Like Normal Physics Objects

Post by ClockworkDice » Fri Jun 29, 2018 5:27 pm

So I'm working on a grappling hook script which allows players to swing around on ropes. However, I've run into a pretty big problem. My original script simply created a distance joint between the player and the "anchor", but because of the way players behave they don't really swing, they just very slowly drift downwards. My original solution (and the best I've come up with so far) was to create a glass shard (it could be any object, but I chose this one at random) at the player's position attached to the rope, and update the player's velocity and position to be equal to that of the shard. This makes the player follow the behavior of a normal physics object. The problem with that is that it makes the player jitter around a bunch due to the way that SetWorldPosition() works. My second solution takes advantage of the fact that a tumbling player has no special physics, and so I just bonk the player in the back of the head with a rock when they start swinging, which makes them tumble and follow physics. The problem with this is that you can't act while in this state, so you can't grapple and swing into a ledge grab, attack, shoot, etc. It also prevents multiple consecutive swings. What I want is for players to follow the physics of a normal object while still being able to attack, shoot, grab ledges, block, etc. Is there any way to do this?

Thanks in advance.

EDIT: I have achieved a similar thing to what I wanted by binding the player to a StoneDebris00A object which swings. It's still slightly jittery, but much better now. Regardless, if anyone does know how to accomplish what I asked above I would love to hear it as it may work better or be cleaner than my solution.

EDIT #2: I have uploaded the new version on sfdmaps if anyone is interested in testing it out
1 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Fri Jun 29, 2018 6:35 pm

You can't make players behave like normal physics objects - because they aren't :)
1 x
Gurt

ClockworkDice
Fighter
Fighter
Posts: 28
Joined: Wed Nov 02, 2016 12:59 am
Started SFD: Sometime in Pre-Alpha
Gender:

Post by ClockworkDice » Wed Jul 04, 2018 6:54 pm

They aren't normal physics objects?
In that case, what happens when a player gets knocked down (into that tumbling, flailing state)? When in that state they behave (mostly) like normal physics objects. They don't have limits on x-axis velocity in that state.
I'm curious, what's going on behind the scenes there? Are you changing the player to a different object? I don't know how the game works behind the scenes so I'm just curious as to how exactly players function in the physics engine
0 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Thu Jul 05, 2018 9:17 pm

Players are real box2D objects in the background but the players influence the object's behaviors, velocity, and other physics related properties to behave like we want players to behave in this game. Once players get knocked down most of that interaction is also paused. But you will never make the players behave like normal physics objects, because they aren't like any other crate, barrel or box in the game.
We also have other objects we influence the physics on- like the balloons and birds which you can't expect to modify with scripting.
0 x
Gurt

ClockworkDice
Fighter
Fighter
Posts: 28
Joined: Wed Nov 02, 2016 12:59 am
Started SFD: Sometime in Pre-Alpha
Gender:

Post by ClockworkDice » Thu Jul 05, 2018 11:41 pm

AH okay thanks, that clears some stuff up.
2 x

Post Reply