Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
3 registered members (AbrahamR, AndrewAMD, ozgur), 763 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Collision and Jump code #130410
05/17/07 15:00
05/17/07 15:00
Joined: May 2007
Posts: 10
Itajaí - SC - Brazil
S
Sputnicker Offline OP
Newbie
Sputnicker  Offline OP
Newbie
S

Joined: May 2007
Posts: 10
Itajaí - SC - Brazil
Hi people, its my first post on this forum.
Sorry about my poor english language... ^^
I'm developing a game with no templates, and I have some problems with the colision and the jump codes...
The colision problem is: I can move ok, but when I'm moving sometimes I can go inside of objects... and can't move back because its colided...
Other bug in colision is that when I go to a wall, if I stay much close to this the player goes up...

The jump problem is: how can I do that? I'm newbie in the gameprogramming, and no know how it works... need I deactivate de gravity while I'm jumping?

Here is the code of my player:

function andarfc
{
var snd;
if tocando == 0
{
snd=snd_play(andarsnd,70,0);
tocando = 1;
wait(16);
snd_stop(snd);
tocando = 0;
}
}

action Playerprinc
{
var move_var; //We're going to use this as our move vector (X,Y,Z)
var tempmypos;
player = me;
my.invisible = on;
while(1) //while the player object exists
{
move_var.x = 0; //resets them all back to 0
move_var.y = 0; //if we don't do thist hen the variables will addup
move_var.z = 0; //making the player move faster and faster with no stopping

if movimento == 1
{
camera.x = player.x;
camera.y = player.y;
camera.z = player.z + 100;
camera.pan = player.pan;
if fase3cn == 0
{player.pan -= sensi*mouse_force.x;
camera.tilt += sensi*mouse_force.y;}
if camera.tilt > 90 {camera.tilt = 90;}
if camera.tilt < -90 {camera.tilt = -90;}

}
tempmypos.x = my.x;
tempmypos.y = my.y;
//tempmypos.z = my.z;
colissssao = c_trace(tempmypos,move_var,ignore_me + ignore_you + ignore_passents + ignore_passable);
vec_set(temp,my.x); //copies the second vector to the first
temp.z -= 8000; //lets make the trace point way way below us
trace_mode = ignore_me+ignore_sprites+ignore_models+use_box; //see manual
result = trace(my.x,temp);
/* if(result > 5) //if from my pos to temp is greater than 5
{ move_var.z -= gravidade; }*/ //fall speed of 20 (higher number, faster falling speed)
if(result > 100) { show_health -= 1; wait(1);}
if(result <= 0) //if from my pos to temp is less than or equal to 0
{ move_var.z += 2; } //not touching the floor but extremely close

if(key_w == on) && (show_health > 0) && (fase3cn == 0) //if we press the up arrow key
{
if (key_shift == on)
{
move_var.x = 8 + fase3; //give the X parameter a value of 4
andarfc();
}
else
{
move_var.x = 4 + fase3; //give the X parameter a value of 4
andarfc();
}
}
if(key_s == on) && (show_health > 0) && (fase3cn == 0) //if we press the down arrow key
{
if (key_shift == on)
{
move_var.x = -6 - fase3; //give the X parameter a value of 4
andarfc();
}
else
{
move_var.x = -2 - fase3; //give the X parameter a value of 4
andarfc();
}
}
if(key_a == on) && (show_health > 0) && (fase3cn == 0) //if we press the left arrow key
{
move_var.y = 4 + fase3; //add to the pan value
andarfc();
}
if(key_d == on) && (show_health > 0) && (fase3cn == 0) //if we press the right arrow key
{
move_var.y = -4 - fase3; //subtract the pan value
andarfc();
}
if(key_space == on) && (pulando == 0) && (show_health > 0) && (fase3cn == 0) //if we press the right arrow key
{
wait(1);
}
if (show_health <= 0)
{
wait(1);
}
move_friction = 0;
c_move(me,move_var,nullvector,IGNORE_PASSABLE+GLIDE+USE_BOX);
wait(1);
}
}

Last edited by Sputnicker; 05/17/07 15:03.
Re: Collision and Jump code [Re: Sputnicker] #130411
05/17/07 19:08
05/17/07 19:08
Joined: May 2007
Posts: 10
Itajaí - SC - Brazil
S
Sputnicker Offline OP
Newbie
Sputnicker  Offline OP
Newbie
S

Joined: May 2007
Posts: 10
Itajaí - SC - Brazil
About the collision problem:
When I go to the feet of an house, the player "lift up" in the wall and go to the ceiling ^^

Re: Collision and Jump code [Re: Sputnicker] #130412
05/17/07 19:23
05/17/07 19:23
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
player.z += is when player is in passable //even if you not set it, thats the engine code
Try to increase bounding box setting around entitys by:
my.fat =on; my.narrow = off;
or set
c_setminmax(me);

Last edited by tompo; 05/17/07 19:24.

Never say never.
Re: Collision and Jump code [Re: tompo] #130413
05/17/07 19:42
05/17/07 19:42
Joined: May 2007
Posts: 10
Itajaí - SC - Brazil
S
Sputnicker Offline OP
Newbie
Sputnicker  Offline OP
Newbie
S

Joined: May 2007
Posts: 10
Itajaí - SC - Brazil
my.fat =on; my.narrow = off;
It doesnt work... the player is aways going up...

c_setminmax(me);
This give a error while run game...

The problen is here:
if(result <= 0) //if from my pos to temp is less than or equal to 0
{ move_var.z += 2; } //not touching the floor but extremely close

When I move to a wall the c_trace think that the top of the wall is the floor and lift me up...
I need a function to not colide at all the player to the wall... ^^

I have no idea of how to do it... ^^

Re: Collision and Jump code [Re: Sputnicker] #130414
05/17/07 19:46
05/17/07 19:46
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
Quote:

When I move to a wall the c_trace think that the top of the wall is the floor and lift me up...



not exacly because you trace -800 so you trace down not ahead

this will keep your entity always on the ground
Code:
 
function gravity
{
vec_set(temp, my.x); temp.z -= 5000;
trace_mode = IGNORE_ME + ignore_models + IGNORE_PASSABLE + IGNORE_SPRITES + use_box + scan_texture;
result = trace (my.x, temp);
my.z -= result;
}



you may of course cut ignore_models if you want


Last edited by tompo; 05/17/07 19:50.

Never say never.
Re: Collision and Jump code [Re: tompo] #130415
05/17/07 22:45
05/17/07 22:45
Joined: May 2007
Posts: 10
Itajaí - SC - Brazil
S
Sputnicker Offline OP
Newbie
Sputnicker  Offline OP
Newbie
S

Joined: May 2007
Posts: 10
Itajaí - SC - Brazil
the same problem... Tompo... You have MSN? I'm thinking in rewrite the player code...
Thanks for the help!

Re: Collision and Jump code [Re: Sputnicker] #130416
05/28/07 16:42
05/28/07 16:42
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Don't use use_box in your trace to the ground.


xXxGuitar511
- Programmer
Re: Collision and Jump code [Re: xXxGuitar511] #130417
05/28/07 17:36
05/28/07 17:36
Joined: Nov 2006
Posts: 141
South Africa
quasarchangel Offline
Member
quasarchangel  Offline
Member

Joined: Nov 2006
Posts: 141
South Africa
/* if(result > 5) //if from my pos to temp is greater than 5
{ move_var.z -= gravidade; }*/ //fall speed of 20 (higher number, faster falling speed)

Why is this commented out?

Try changing the following into the blue code below.

/* if(result > 5) //if from my pos to temp is greater than 5
{ move_var.z -= gravidade; }*/ //fall speed of 20 (higher number, faster falling speed)
if(result > 100) { show_health -= 1; wait(1);}
if(result <= 0) //if from my pos to temp is less than or equal to 0
{ move_var.z += 2; } //not touching the floor but extremely close

if(result > 5) //if from my pos to temp is greater than 5
{ move_var.z = -5; } //fall speed of 20 (higher number, faster falling speed)
//if(result > 100) { show_health -= 1; wait(1);}
if(result < 5) //if from my pos to temp is less than or equal to 0
{ move_var.z = -result; } //not touching the floor but extremely close


Hope it works.

Whats the "if(result > 100) { show_health -= 1; wait(1);}" for? Why "wait(1);" after it?


God DID give us a manual on how to change this world...
Re: Collision and Jump code [Re: quasarchangel] #130418
05/28/07 18:25
05/28/07 18:25
Joined: Mar 2003
Posts: 4,264
Wellington
Nems Offline

.
Nems  Offline

.

Joined: Mar 2003
Posts: 4,264
Wellington
var move_min_z = 0; is what you are looking for, example set to 0, actor will climb any angle.
Set to 4 or 6, restrain to 40 to 60 degrees respectivly but it depends on the models size and where the origin is set.

refer to manual for more info.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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