Probleme mit dem gravity code/problems with gravity

Posted By: tagimbul

Probleme mit dem gravity code/problems with gravity - 01/20/16 00:04

GERMAN: hei i have this problem here

ENGLISH: hey ich habe dieses problem hier

https://www.youtube.com/watch?v=2sCFtbuN-Mk

GERMAN: wie kann ich steuern, ab welcher höhe der bounding box er diesen "jump" ausführt?

ENGLISH: How can I control from which height of the bounding box, he executes this "jump"?
Posted By: Dico

Re: Probleme mit dem gravity code/problems with gravity - 01/20/16 00:52

maybe you need this move_min_z = 0.4; add it to your main
Posted By: 3run

Re: Probleme mit dem gravity code/problems with gravity - 01/20/16 06:44

Hi.

As I see, you are using the code from Superku's TipOfTheWeek series. As far as I remember, small box like BBOX was part of the 'setup', so making it as big as your player's model will mess things up. You probably edited this lines in your code:
Code:
vec_fill(my.min_x,-32);
vec_fill(my.max_x,32);

And I think, you shouldn't do that. I'm pretty sure Superku will give a better reply about his code.
Anyway, this is how it should look like to work correctly (as in his example and as in your first part of the video):




Best regards!
Posted By: tagimbul

Re: Probleme mit dem gravity code/problems with gravity - 01/20/16 08:33

i have set the bbox..

by the first part of the video is the bbox zu small by the second part ist the bbox on this size tath i want but if i move on a block he bzg/jump upside and i need to controll this

look on 0:39
https://youtu.be/2sCFtbuN-Mk?t=39s

if the BBOX to high, he jump upside.
i want the BBOX on this size and i want control the bug/jump high with a variable...

I struggle with this problem for a long time period
but it could never solve
Posted By: 3run

Re: Probleme mit dem gravity code/problems with gravity - 01/20/16 10:36

Originally Posted By: tagimbul
i have set the bbox..

by the first part of the video is the bbox zu small by the second part ist the bbox on this size tath i want but if i move on a block he bzg/jump upside and i need to controll this
That's the thing I'm trying to tell you. This code won't (probably) work with rectangular BBOX! You have to use square BBOX (as on the picture from original source I've posted above and as in the first part of your video!). To make sure, you have to wait for Superku's reply, cause he is the one who made that gravity code, and I'm pretty sure he made square BBOX for a reason.

Originally Posted By: tagimbul
if the BBOX to high, he jump upside.
i want the BBOX on this size and i want control the bug/jump high with a variable...

I struggle with this problem for a long time period
but it could never solve
This caused by ellipsoid shape of collusion bbox ( READ MANUAL ), and we all suffering from this :< You can try and change 'move_min_z' parameter as Dico suggested, but I'm sure it won't help (it may reduce the stepping height, but will cause to other issues that you'll need to fix), cause there is no ONE variable that will solve that problem, it's pretty tricky to get working collusions properly. It may sound really frustrating I know this on my own, cause I'm been suffering from Acknex's OBB collision engine for years. You may want to check physX engine too, but it's also undone and tricky (and out-dated as hell). Take a look at the contribution I've made here:
PhysX Movement (RIGID BODY)


Best regards.
Posted By: tagimbul

Re: Probleme mit dem gravity code/problems with gravity - 01/20/16 11:51

slowly I understand it ...
with an ellipsoid and move_min_z I can choose, at what level he skips the stairs?
you mean this?



A = skip the stair. while the normal contact is okey
B = no skip . while the normal kontakt is to big?
and i can set it with move_min_z ?
Posted By: 3run

Re: Probleme mit dem gravity code/problems with gravity - 01/20/16 12:41

Originally Posted By: tagimbul
slowly I understand it ...
with an ellipsoid and move_min_z I can choose, at what level he skips the stairs?
you mean this?



A = skip the stair. while the normal contact is okey
B = no skip . while the normal kontakt is to big?
and i can set it with move_min_z ?
Quote from manual:
Quote:
By default the ellipsoid can move up any slope, no matter how steep it is. To restrict this motion you can alter the global variable move_min_z. If the contact normal's Z axis is less than this minimum value no gliding along Z will take place at all. Hitting the ground plane will result in a normal.z value of 1.0 (pointing straight up). Hitting the ceiling will yield -1.0 (straight down) and a head on collision with a perpendicular wall will have a normal.z value of 0. The default value of move_min_z is -1 which allows gliding at all angles. If you were to set it to 0.5 instead all slopes steeper than 60 degrees (=acos[0.5]) would cause the entity to stop and not glide up. This example is valid only for a spherical hull. For an ellipsoid some trial and error is required to find the right value. Rather than relying on move_min_zit is recommended that you place invisible entities in front of steep walls to block them off.
It means that 'move_min_z' determines the angle of the slope entity can step on. You have to know, that those 'black' obstacles in your picture, will affect normal.z too, as you try to step on them they will return 0 (probably). So playing around with 'move_min_z' may help, but as the manual says it's not a thing to rely on. It will cause other problems anyway at the end, probably cause to get that 'normal.z' value, you have to collide with those 'obstacles' at first, and after that they are too steep entity won't step on them.. I tried to find german manual, to make quote from it (instead of english version), but I couldn't find it. Read more about collision engine, you'll find out that it's really tricky to get properly working movement code :<

I tried to explain how it works via this picture:

The red silhouette that goes down from the entity is the 'c_trace' with USE_BOX flag set on, you have to know that it's using ellipsoid as well. Also, to understand what 'move_min_z' sets you have to imagine a slope going more and more steeper from flat ground (pointing straight up) which has angle 0 to a vertical wall, that has angle 90 (let's say), in this situation setting 'move_min_z' to 0.5 will prevent entity from GLIDING (this is very important) up on the slope, which's angle is steeper than 60 degrees (as the manual says, you can convert those 'move_min_z' values (1-0) into the angle of the slope by 'acosv' function, f.e. acosv(0.5) will equal to 60). Prevent from GLIDING means, that it will get stuck on moving up on the slope, and that is something that will result to unwanted results at the end. I tried my best to explain grin Keep it up!


My best regards!
Posted By: Superku

Re: Probleme mit dem gravity code/problems with gravity - 01/22/16 12:01

"This code won't (probably) work with rectangular BBOX! You have to use square BBOX"
The code theoretically works with all kinds of bboxes, square or not.

The problem is, as already identified, the OBB collision system. Because of that you can move the player's hull at least to some degree over a corner, and the USE_BOX trace, starting from let's say the middle of the player position, will then hit the ground on the downward trace.
As 3run already said this is a tricky one to solve - or at least to find workarounds -, especially in three dimensions. Maybe a separate small collision hull (entity) near the feet with a separate c_move could do the trick (then limit the player's movement/ c_move call accordingly).
Posted By: 3run

Re: Probleme mit dem gravity code/problems with gravity - 01/22/16 13:08

Originally Posted By: Superku
"This code won't (probably) work with rectangular BBOX! You have to use square BBOX"
The code theoretically works with all kinds of bboxes, square or not.
Well, maybe I used few wrong words to explain myself there. It will be MORE tricky to make it work with rectangular BBOX grin
Posted By: Superku

Re: Probleme mit dem gravity code/problems with gravity - 01/22/16 13:26

Yeah that's true.

If the level geometry is mostly grid aligned (meaning few diagonals and such) you can for example put min_x/max_x to something small (0.01) temporarily, do a trace in x-direction, reset min/max, same for y, and use "target" positions to limit player movement. I do something like that in my sidescroller as it emulates a box (or in 3D cylindrical) trace more or less easily.
Posted By: 3run

Re: Probleme mit dem gravity code/problems with gravity - 01/22/16 14:39

I already failed before for a few times, but I'll try it once again grin

Lower box used for gravity (will use Superku's gravity script) and the upper one for XY movement.
Maybe this time with some tweaks I'll be able to get something working... Who knows.


Best regards!
Posted By: 3run

Re: Probleme mit dem gravity code/problems with gravity - 01/22/16 21:11

I've made a small demo, it turned out pretty nice at the end (with auto-jumping thing). Give it a try:
Download link

Edit: I made a little contribution out of it.

Greets
Posted By: tagimbul

Re: Probleme mit dem gravity code/problems with gravity - 01/23/16 01:38

<3 love it thx grin
Posted By: 3run

Re: Probleme mit dem gravity code/problems with gravity - 01/23/16 06:54

Originally Posted By: tagimbul
<3 love it thx grin
You are welcome. Try updated version from the contribution thread (link above workds too), I've fixed some bugs and reuploaded it.

Greets
Posted By: tagimbul

Re: Probleme mit dem gravity code/problems with gravity - 01/23/16 12:19

you are awesome grin
© 2024 lite-C Forums