|
|
Gravity
#419245
03/08/13 09:39
03/08/13 09:39
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
Everytime I run my program in SED, my guard model always ends up standing and walking in the air over the ground instead of standing and walking on the ground inside the castle I created in WED, even though I have the model standing on the ground in WED. I tried using some code taken from a Lite-C tutorial on keeping a model character on the ground, but so far it is failing me. This is the code:
action walking_guard() { camera_follow(me); c_setminmax(me); // set my bounding box to my real size VECTOR vFeet; vec_for_min(vFeet,me); // vFeet.z = distance from player // origin to lowest vertex my.STATE = 1; while (1) { // state 1: walking /////// if (my.STATE == 1) { // rotate the entity with the arrow keys my.pan += (key_cul-key_cur)*5*time_step;
// move the entity forward/backward with the arrow keys var distance = (key_cuu-key_cud)*5*time_step; c_move(me, vector(distance,0,0), NULL, GLIDE); // animate the entity my.ANIMATION += 2*distance; ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE); // adjust entity to the ground height, using a // downwards trace c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE); my.z = hit.z - vFeet.z; // always place player's // feet on the ground } wait(1); }
Any clue why my guard always ends up standing in the air when I run my program, instead of standing on the ground like it is supposed to?
|
|
|
Re: Gravity
[Re: PadMalcom]
#419250
03/08/13 10:24
03/08/13 10:24
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
exaclty, for example:
wait(1); my.eflags |= FAT | NARROW; // set both flags to prevent automatic recalculation on scale changes vec_set(my.min_x,vector(-10,-10,-10)); // set bounding box to individual values vec_set(my.max_x,vector(10,10,30));
c_setminmax is not okay to be used for characters
Last edited by sivan; 03/08/13 10:25.
|
|
|
Re: Gravity
[Re: PadMalcom]
#419261
03/08/13 13:50
03/08/13 13:50
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
Hey Ruben,
you have to adjust the bounding box around the model. Every model has a collision hull that is used for functions like c_move or c_trace. This model gets visible when you hit F11 twice. You can adjust it by playing with the "min_x..z" / "max_x..z" values of your player entity. Hello PadMalcom, Can you tell me which function uses these min_x.z and max_x.z variables to change the size of the collision hull?
|
|
|
Re: Gravity
[Re: PadMalcom]
#419335
03/09/13 02:49
03/09/13 02:49
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
Have a look at "min_x" in the help. You simply have to adopt "player.min_x", "player.min_y" and "player.min_z" to your needs. Look at sivans code to see how it cound be done. It is easy Is this where Savin's code can be found (I found this on Savin's website: http://mapbuilder.zxq.net/ )?: http://tutorial.3dgamestudio.net/If so, the only way I see that this tutorial tries to shrink the collision hull is by using: c_setminmax(me); // set my bounding box to my real size When I use this function, and press the f11 key twice to see the collision hull, it looks like the hull is pretty snuggy up to the player, and the bottom of the hull is in the air touching the player's feet, but both the bottom of the collision hull and the bottom of the player's feet are well above the ground in the level. I cannot figure out how to bring the character's feet down to ground level. I also cannot find any examples on how min_x, min_y, and min_z are used. Only information about them. If anyone can post a link to a webpage that does show an example on how they're used, I would greatly appreciate it.
|
|
|
Re: Gravity
[Re: Ruben]
#419355
03/09/13 12:20
03/09/13 12:20
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
I notice that when I take this piece of code out of the program:
my.z = hit.z - vFeet.z; // always place player's // feet on the ground
...the bottom of my character's feet finally reach the ground. When my character walks against an object, like a table, the character will walk up on top the table. But when I try to move the character off the table, the character stays up in the air at the same vertical level the character was at while on the table, instead of falling to the ground like the character should.
I am assuming that I need to keep the code above, and at the same time figure out a way to bring the character down to ground level. It seems like the code above is somehow causing the character to walk up in the air. I took this code off the Lite-C tutorial, with the Basic Shooter game involving the red wizard. It works for the red wizard, so I am wondering why it is not working for my character.
|
|
|
Re: Gravity
[Re: Ruben]
#419402
03/09/13 20:04
03/09/13 20:04
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
VECTOR vFeet;
vec_for_min(vFeet,me);
c_trace(my.x,vector(my.x,my.y,my.z-100),IGNORE_ME | IGNORE_PASSABLE|USE_BOX|IGNORE_CONTENT);
my.z = hit.z - vFeet.z;
that works for me
Last edited by Wjbender; 03/09/13 20:06.
Compulsive compiler
|
|
|
|