[BEHAVIOR] Sonic Physics

Post your work in progress addons and get feedback

Post » Sun Aug 09, 2015 9:04 am

@PixelMonkey
Thanks, I'm eagerly waiting. I'm working on art assets in the meantime, so it's not like my life depends on it :) The behavior is very useful though, and a very solid cornerstone of my game's mechanics. Without it I'd still be breaking my head open trying to figure out everything through events (which I actually did but does not work even half as good and painless).
Image
Image
Image
B
15
S
2
Posts: 48
Reputation: 1,597

Post » Wed Aug 26, 2015 5:11 am

Alright, small update to the behaviour. Again, so sorry about the wait. Had I known I'd be this busy I'd have waited until I could provide more regular updates.

Changes:

Air drag now works

Simulate Jump now works again

Can now specify an angle threshold for when the downhill slope factor will have an effect.

Issue with 45 degree slopes locking controls fixed


@KZR:
Found that slope issue you were talking about! When the object stops moving on a slope (assumed to be because it's too steep) the engine locks horizontal controls for a fraction of a second while the slope factor kicks in and pushes the player downhill a bit. Generally this is a good thing, since you don't want the player on a slope they can't walk up just pushing against it, but with slope factor disabled (which I'm assuming is what you did?) and when on a 45 degree slope (also assuming you did that) it triggers the lock, doesn't push the player down, and just sits there counting down the horizontal control lock and repeatedly triggering it again when it hits 0.
The threshold for the angle is 45 (non-inclusive), but with swapping between radians and degrees being a little unexact it's counting 45.0000012522 as being above 45. Which it is. I've changed it so it's a parameter defaulting to 46: FallingAngleThreshold. If the slope is shallower than that, falling off should not trigger. Should fix the issue as it currently is, as well as allowing some fine-tuning if it still presents a problem.


There are a couple obvious issues still present that I really need to work on (including tilemaps, which I will get to, I promise!), but if I'm honest I'd still expect things to be a little slow on my end for a bit longer yet. Please keep letting me know if there are any issues, and I'll try to solve them as soon as I can!

Also, regarding rotation and the Set Angle property, I've had a quick go at it and ran into issues reliably moving things around so as not to clip a non-square bounding box into terrain or off a slope it should be sticking to. It isn't ideal, but as a workaround I'd recommend keeping the collision poly for the main object square, and overlapping another object with a non-square poly if you need one for other collisions.

I'm getting to the point where my inexperience with some of this is showing, so if it comes to it, please bear with me as I try to refactor things to make future changes more feasible.
B
75
S
27
G
12
Posts: 127
Reputation: 11,765

Post » Thu Aug 27, 2015 9:19 pm

I've got my eye on this. ;)
Great work so far!
B
24
S
5
G
6
Posts: 35
Reputation: 4,295

Post » Sat Aug 29, 2015 8:16 pm

I'm either doing something wrong or reaching a point where I want the behavior to do more than it can. Either way, if I stop on a slope, regardless of angle, with slope up/downhill threshold activated, and even with high acceleration, I can't move. I updated the behavior to the latest version and left the minimum angles at 0.

I think I'm not getting the right relation between friction, acceleration and slope factor. If it's not that, HELP!

See for yourself in the CAPX:

https://www.dropbox.com/s/xinz6s37qep4aqx/PhysicsYUNOWORK.capx?dl=0
Image
Image
Image
B
15
S
2
Posts: 48
Reputation: 1,597

Post » Mon Aug 31, 2015 2:31 am

@KZR
To clarify, the new Falling Angle Threshold property should be set to 46 to make this work (in the last version, this was hardcoded as 45, which was 1 degree off). With it at 0 I can see the issue, but setting it to 46 fixes it.
B
75
S
27
G
12
Posts: 127
Reputation: 11,765

Post » Mon Aug 31, 2015 8:30 pm

It works better now, thanks :D

I'll keep you posted on any other stuff I may find
Image
Image
Image
B
15
S
2
Posts: 48
Reputation: 1,597

Post » Sat Sep 05, 2015 7:56 pm

Just in case it may help you, I used to work with this engine, which is open source and recreates Sonic physics pretty well. If you can read C code, it might be of help. The code you're looking for is mostly in physics_actor.c.

http://sourceforge.net/p/opensnc/code/H ... rge/trunk/
Image
Image
Image
B
15
S
2
Posts: 48
Reputation: 1,597

Post » Mon Sep 07, 2015 3:02 am

Ah cool, looks like a pretty solid implementation there. There are a few things I've done differently (mostly to mimic the Platform behaviour where it doesn't remove accuracy) but it could be good for reference. Thanks!
B
75
S
27
G
12
Posts: 127
Reputation: 11,765

Post » Wed Sep 09, 2015 2:45 am

Trying to install but it says info.xml is missing from the root.
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Wed Sep 09, 2015 8:52 am

@Tokinsom
Ah, sorry, fixed. Really need to start double-checking things before I upload them.
B
75
S
27
G
12
Posts: 127
Reputation: 11,765

PreviousNext

Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 1 guest