2 registered members (AndrewAMD, Ayumi),
1,384
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Jumping screws up collision
#391340
01/10/12 23:08
01/10/12 23:08
|
Joined: Mar 2009
Posts: 186
Valdsator
OP
Member
|
OP
Member
Joined: Mar 2009
Posts: 186
|
I have a simple problem in my game at the moment. When there's a doorway or a vent in my game, jumping at the wall above it results in the player moving through the wall once he has landed. I want to prevent this from happening. I made the player automatically crouch if this happened, but it gets in the way of other things, and is a rather rough fix. NOTE: This image isn't completely accurate. The open space below has to be a bit bigger. What's shown above wouldn't actually result in the player moving through the wall. Anything I can do to prevent this?
|
|
|
Re: Jumping screws up collision
[Re: Valdsator]
#391349
01/11/12 02:16
01/11/12 02:16
|
Joined: Dec 2009
Posts: 256 USA , NY
msmith2468
Member
|
Member
Joined: Dec 2009
Posts: 256
USA , NY
|
well how do you have it set up? are you using c_move? do you have USE_BOX set with a FAT or NARROW haul? I guess i don't really have enough information to help you. It appears from your drawing that the majority of you players body is going through a wall which means that your collisions box must be smaller then the player. did you use c_updatehull? Here is a link to Game Studios Collision Engine details. http://www.conitec.net/beta/collision.htm
|
|
|
Re: Jumping screws up collision
[Re: msmith2468]
#391351
01/11/12 03:39
01/11/12 03:39
|
Joined: Mar 2009
Posts: 186
Valdsator
OP
Member
|
OP
Member
Joined: Mar 2009
Posts: 186
|
Yes, I'm using c_move. I have the eflags FAT and NARROW set so I can change the collision box. Increasing the width and length of it doesn't seem to help, since once the player gets inside a block, nothing stops him. Collision with that block doesn't work until he gets out himself. No, I did not use c_updatehull, I manually set the max_x and min_x.
The red oval in my drawing is representing the collision ellipsoid of the player, and I have it set to be as big as the player model, except for the bottom, which is a bit shorter than the actual model. Making it the proper length doesn't fix the issue, though.
max_x is 8, 8, 45 min_x is -8, 8, -20
I think one thing causing the issue is the fact that the collision box is an ellipsoid. Since there's an opening, some of the ellipsoid is able to go through before colliding with the upper wall. Of course, this isn't the main reason, because I can do this without jumping, which simply results in the player getting slightly closer, and gliding horizontally getting all jittery.
|
|
|
Re: Jumping screws up collision
[Re: Carlos3DGS]
#391430
01/11/12 23:37
01/11/12 23:37
|
Joined: Mar 2009
Posts: 186
Valdsator
OP
Member
|
OP
Member
Joined: Mar 2009
Posts: 186
|
I use c_move for gravity, yes. I use GLIDE on this c_move. I set max_x and min_x via vec_set.
vec_set(my.max_x,vector(8,8,45));
vec_set(my.min_x,vector(-8,-8,-20));
The reason for the bottom being only 20, while the top is 45 is because I use a c_trace to check for the floor, allowing the player to walk up stairs and such. Setting the -20 to -45 doesn't solve the issue, and since the c_trace is shooting downward, I don't think that's causing the problem (I think I'll test this just in case). I tried c_setminmax(me); just now, but that didn't solve it. That's also a bit inconvenient due to the reason stated above. The character rotates using my.pan -= mickey.x; I just tried using c_rotate, but that didn't change anything.
|
|
|
Re: Jumping screws up collision
[Re: 3run]
#391484
01/13/12 02:56
01/13/12 02:56
|
Joined: Mar 2009
Posts: 186
Valdsator
OP
Member
|
OP
Member
Joined: Mar 2009
Posts: 186
|
30 * time_step is the top speed, but I don't think that's the problem. I just made a new project with the same level and player model, same horizontal movement code, but a simple jump system, and now the issue is gone. Also, when the player glides against the vent, the reaction isn't so jittery. I have other code in the player of course, so I really don't know what's causing this problem. I'm going to do more tests and see if I can fix it. EDIT: Ok, I replaced my old vertical movement code with the simple jump code and the issue has disappeared. I guess I'll go and try changing certain lines to see what specific code is causing the problem, and see if I can change it. EDIT 2: Alright, so apparently it's the code that allows the player to go up slopes and stairs easily. More specifically, it's the code that snaps the player to the ground/slope (using my.z = ) so it's a smooth climb up or down. I guess I just need to find a different way to accomplish this. Thanks to everyone who helped!
Last edited by Valdsator; 01/13/12 03:12.
|
|
|
Re: Jumping screws up collision
[Re: Carlos3DGS]
#391505
01/13/12 13:56
01/13/12 13:56
|
Joined: Oct 2008
Posts: 513
Carlos3DGS
User
|
User
Joined: Oct 2008
Posts: 513
|
-Do you ever modify the x/y/z or pan/tilt/roll directly in another part of your code? (outside of the c_move/c_rotate functions) Ok a possible solution to your problem that will allow you to keep your code that calculates climbing up/down slopes smoothly... Take the calculations from your "my.z = blablabla;" but instead of assigning it directly to my.z do something like this: z_difference = my.z-(blablabla); c_move(me,nullvector,vector(0,0,-z_difference),FLAGS); That should give the same result you had before but it now considers collisions. hope this helped!
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|