Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, The_Judge, Grant), 898 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Gravity #419245
03/08/13 09:39
03/08/13 09:39
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline 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: Ruben] #419246
03/08/13 09:45
03/08/13 09:45
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
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.

Re: Gravity [Re: PadMalcom] #419250
03/08/13 10:24
03/08/13 10:24
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
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.

Free world editor for 3D Gamestudio: MapBuilder Editor
Re: Gravity [Re: PadMalcom] #419261
03/08/13 13:50
03/08/13 13:50
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Originally Posted By: PadMalcom
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: Ruben] #419262
03/08/13 13:53
03/08/13 13:53
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
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 laugh

Re: Gravity [Re: PadMalcom] #419335
03/09/13 02:49
03/09/13 02:49
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Originally Posted By: PadMalcom
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 laugh

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] #419354
03/09/13 12:10
03/09/13 12:10
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline 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.

Re: Gravity [Re: Ruben] #419355
03/09/13 12:20
03/09/13 12:20
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Originally Posted By: Ruben
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
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
Code:
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
Re: Gravity [Re: Wjbender] #419404
03/09/13 20:16
03/09/13 20:16
Joined: May 2009
Posts: 5,365
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,365
Caucasus
Take a look at the wizard model first, if it's origin placed at it's center or below it's feet. Then, place the origin of your model at the same way. This might help.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Page 1 of 2 1 2

Moderated by  HeelX, rvL_eXile 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1