Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
little, little problems with walk around #300900
12/06/09 18:06
12/06/09 18:06
Joined: Jul 2009
Posts: 150
B
Blackchuck Offline OP
Member
Blackchuck  Offline OP
Member
B

Joined: Jul 2009
Posts: 150
So I have a chareckter that walks around without any paths, but;
1.He walks over Passable.
2.He has no gravity.

code;
_______________________________________________________________
action walker_man()
{
VECTOR temp[3];
VECTOR front_pos;
var distance_covered;
var distance_to_ground;
my.emask |= (ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_BLOCK);
c_setminmax(me);
my.event = die_soldier;
while (1)
{
vec_set (temp.x, my.x);
temp.z -= 10000;
distance_to_ground = c_trace (my.x, temp.x, IGNORE_ME | USE_BOX | IGNORE_PASSABLE);
vec_set(front_pos.x, vector(500, 0, 0));
vec_rotate(front_pos.x, my.pan);
vec_add(front_pos.x, my.x);
if (c_content(front_pos.x, 100) == 1)
{
distance_to_ground = c_trace (my.x, temp.x, IGNORE_ME | USE_BOX | IGNORE_PASSABLE) -20;
distance_covered = c_move(my, vector(10 * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE);
my.skill22 += 7 * time_step;
ent_animate(my, "ComNwForward", my.skill22, ANM_CYCLE);
}
else
{
my.skill99 = 0;
while (my.skill99 < 0.5)
{
my.skill99 += time_step / 16;
ent_animate(my, "ComNormalStand", my.skill22, ANM_CYCLE);
my.skill22 += 7 * time_step;
wait (1);
}
my.skill99 = my.pan;
my.skill99 += random(180);
while (my.pan < my.skill99)
{
my.pan += 5 * time_step;
ent_animate(my, "ComNwRight", my.skill22, ANM_CYCLE);
my.skill22 += 7 * time_step;
wait (1);
}
}
wait (1);
}
}
_______________________________________________________________

Hop somebody can help.
(Im sure somebody can help)


I have know Gamestudio/A7 Commercial Edition 7.84
Re: little, little problems with walk around [Re: Blackchuck] #300909
12/06/09 20:02
12/06/09 20:02
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Well, these problems aren't quite so little.

First off, your character isn't falling because he hasn't been instructed to. When you call c_move(), you tell him to move forward, but you don't check to see how far he is above the ground and give him a negative z distance so he can fall. In fact, you don't do anything with "distance_to_ground", which is rather inefficient.

The thing about "poor-man's-physics" is that your characters aren't affected by gravity the way physics objects are. You have to manually check how high above the ground they are, and if they are too high, you must give them a negative Z distance value.

Also, you shouldn't trace downwards 1000 quants. If the ground is farther than 1000 quants, or any number for that matter, the function returns a zero, which in this case isn't good for much. You should only trace down 5 quants or so, and if the ray doesn't hit anything (ie, returns a zero), then you should make the character fall. That's much more efficient.

For example:

Code:
action moving_character()
{
  // some variables
  var dist_to_ground;
  var dist[3];

  // give me a bounding box
  my.fat = on;
  my.narrow = on;

  // make sure the b-box is equally long on all sides to prevent "hitching" while rotating
  if( my.min_x < my.min_y ) { my.min_y = my.min_x; }
  if( my.max_x > my.max_y ) { my.max_y = my.max_x; }
  if( my.min_y < my.min_x ) { my.min_x = my.min_y; }
  if( my.max_y > my.max_x ) { my.max_x = my.max_y; }

  while( my ) // only loop as long as I exist
  {
    vec_set( temp.x, my.x );
    temp.z -= 5; // trace down only 5 quants
    dist_to_ground = c_trace( my.x, temp.x, ignore_passable+ignore_me+use_box );

    if( dist_to_ground == 0 ) // no ground below me?
    {
      dist.x = 3; // move slow in mid-air
      dist.y = 0; // no sideways movement
      dist.z = -10; // gravity
    }
    if( dist_to_ground <= 5 && dist_to_ground != 0 ) // found ground?
    {
      dist.x = 6; // move quickly on land
      dist.y = 0; // no sideways movement
      dist.z = 0; // no gravity on the ground
    }

    c_move( my, dist, nullvector, ignore_passable+glide ); // move me according to "dist"

    wait(1);
  }
}



I should note that I use C-Script in this example, which is what I am accustomed to. You might have to fix the syntax up a little.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: little, little problems with walk around [Re: Redeemer] #301933
12/15/09 13:40
12/15/09 13:40
Joined: Jul 2009
Posts: 150
B
Blackchuck Offline OP
Member
Blackchuck  Offline OP
Member
B

Joined: Jul 2009
Posts: 150
Thats no problem.
If there`s sombody interest, it works like this in lite-c;

___________________________________lite-c_______________________________________
VECTOR temp;

action moving_character()
{
var dist_to_ground;
VECTOR dist[3];

my.eflags &= ~FAT;
my.eflags |= NARROW;

if( my.min_x < my.min_y ) { my.min_y = my.min_x; }
if( my.max_x > my.max_y ) { my.max_y = my.max_x; }
if( my.min_y < my.min_x ) { my.min_x = my.min_y; }
if( my.max_y > my.max_x ) { my.max_x = my.max_y; }

while(my)
{
vec_set(temp.x, my.x);
temp.z -= 5;
dist_to_ground = c_trace(my.x, temp.x, IGNORE_ME | USE_BOX | IGNORE_PASSABLE);

if( dist_to_ground == 0 )
{
dist.x = 3;
dist.y = 0;
dist.z = -10;
}
if( dist_to_ground <= 5 && dist_to_ground != 0 )
{
dist.x = 6;
dist.y = 0;
dist.z = 0;
}
c_move(my,dist,nullvector, IGNORE_PASSABLE | GLIDE);
wait(1);
}
}
________________________________________________________________________________

Thanks Redeemer. laugh


I have know Gamestudio/A7 Commercial Edition 7.84

Moderated by  HeelX, Spirit 

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