Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 803 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19056 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 4 1 2 3 4
Jumping troubles #205303
05/05/08 18:21
05/05/08 18:21
Joined: Apr 2007
Posts: 249
Louisana, USA
Ilidrake Offline OP
Member
Ilidrake  Offline OP
Member

Joined: Apr 2007
Posts: 249
Louisana, USA
I've looked everywhere, KHMovement, FPS guides, the manual, these forums and I can't find a solution to my jumping problem. The code works, just not smoothly. I want a nice steady arc upward and downward at the same speed like the old Mario games jumping. The code below works it's just sometimes the player will hang in the air and "fly" before they come back down. Can anyone help me out and tell me what I'm doing wrong?

action players_vehicle
{
player = me;
my.falling = 0;
my.shadow = on;

while (lives > 0)
{
vec_set(temp,my.x);
temp.z -= 1000;

my.fall_distance = c_trace(my.x, temp, IGNORE_ME|IGNORE_PASSABLE|IGNORE_SPRITES|ACTIVATE_SONAR|SCAN_TEXTURE|USE_BOX);

//check if jumping
if (my.jumping != 0)
{
if (my.jump_height > 256 && my.jumping == 1)
{
my.jumping = 0;
move_vec.z = 0;
my.jump_height = 0;
}
else
{
if (move_vec.z > 1*time)
{
move_vec.z -= .3*time;
my.jump_height += move_vec.z;
}
else
{
move_vec.z = 1*time;
my.jump_height += move_vec.z;
}
}
}

//check if falling
if (my.fall_distance > 500 && sign(my.fall_distance) != -1 && my.jumping == 0)
{
my.falling = 1;
}
else
{
if (my.fall_distance < 500 && my.falling == 0 && my.jumping == 0)
{
move_vec.z = -my.fall_distance*time;
}
}
if (my.fall_distance > 256)
{
my.falling = 1;
if (move_vec.z > -20*time)
{
move_vec.z -= .3*time;
}
}


if (key_j)
{
if (my.jumping == 0 && my.falling == 0 && my.fall_distance < 1)
{
my.jumping = 1;
move_vec.z = 45 * time;
}
}



move_vec[0] = (key_cur + key_cul)*25 *time;
if (key_cur == 1){my.pan = 0;}
if (key_cul == 1){my.pan = 180;}

c_move(me,move_vec,nullvector,IGNORE_PASSABLE|GLIDE);
player_animate();
handle_camera();
wait(1);
}
}

function player_animate()
{
my.skill1 += 3*time_step;
if (my.skill1 > 100) {my.skill1 -= 100;}
if (my.falling == 1)
{
if (my.fall_distance < 0)
{
move_vec.z = -my.fall_distance*time;
}
else
{
my.falling = 0;
}
}

if (move_vec[0] == 0 && move_vec[1] == 0)
{
ent_animate(me,"idle",my.skill1,ANM_CYCLE);
}
else
{
ent_animate(me,"roll",my.skill1,ANM_CYCLE);
}
}

function handle_camera()
{
camera.x = my.x;
camera.y = my.y - 1500;
camera.z = my.z + 100;
camera.pan = 90;
}


Just Because Your Paranoid Doesn't Mean They Aren't After You...Because They Really Are

http://spearbang.awardspace.com/news.php
Re: Jumping troubles [Re: Ilidrake] #205346
05/05/08 23:12
05/05/08 23:12
Joined: Apr 2007
Posts: 249
Louisana, USA
Ilidrake Offline OP
Member
Ilidrake  Offline OP
Member

Joined: Apr 2007
Posts: 249
Louisana, USA
*bump* come on someone has to have something. I'm writing up a tutorial on creating a side-scroller but unless I can figure this jump script out it aint gonna happen.


Just Because Your Paranoid Doesn't Mean They Aren't After You...Because They Really Are

http://spearbang.awardspace.com/news.php
Re: Jumping troubles [Re: Ilidrake] #205495
05/06/08 20:14
05/06/08 20:14
Joined: Oct 2007
Posts: 116
S
sydan Offline
Member
sydan  Offline
Member
S

Joined: Oct 2007
Posts: 116
Okay my way is kinda crazy simple and basically works like real life. I don't know if it will help.

Youre player has 3 alocated skils for absolute movement so in c_move you put

c_move(me,vector(my.speedx,0,0), vector(my.absx, my.absy, my.absz), GLIDE)

where absx absy and absz are the absolute (i.e. aligned to room axis) movements

Somewhere you do a trace that checks to see if the player is NOT on the floor if so you increase the my.absz by your gravity amount. If the player is on the floor then the increasing the my.absz stops so they nolonger accelerate and my.absz = 0 so they stop falling.

For jumping all you do is check that the player is on the ground then if it is, when a key is pressed my.absz = 20 (or some suitable value) this cause the player to jump up in the air and then the gravity kicks in dropping them back to the ground smoothly.

um yeah I rushed that so if it didn't make sense here's my current game code showing the trace that handles the whole thing.

 Code:
// gravity trace
		vec_set(temp.x, my.x);  // copies entity x/y/z/ to the temp vector
      temp.z -= 99999; // we set the temp vector ? quants straight down, below the entity
		result = c_trace(my.x,temp.x,IGNORE_ME|IGNORE_PASSABLE|USE_BOX|USE_POLYGON|IGNORE_PUSH); // do a trace and make result = to the found value
		if(result > 0) // chech to see if an obstacle was hit, if so start the falling action
		{
			my.absz -= my.grav_acc*time; // fall
			my.res = 0.2;
		}
		if((result < 60) && (result > 0)) // check to see if the entity is on the ground, if so stop falling
		{
			my.absz = 0;
			my.res = 0.5;
		}
		if((result < 40) && (result >0)) // check if entity is bellow ground (fallen through) if so rise up
		{
			my.absz += 40*time;
			my.res = 0.5;
		}
		if(result == 0) // if nothing is bellow the entity i.e. outside room area, then gravity stops
		{
			my.absz -= my.grav_acc*time;
		}
 



If you need help with my rushed message I will probably be around some other time to reexplain it I have to go so I hope that helped.

Sydan


For some reason, my ambition always seems to beat my ability.
Re: Jumping troubles [Re: sydan] #205534
05/07/08 03:20
05/07/08 03:20
Joined: Apr 2007
Posts: 249
Louisana, USA
Ilidrake Offline OP
Member
Ilidrake  Offline OP
Member

Joined: Apr 2007
Posts: 249
Louisana, USA
Thanks man!!!!!!! That totally makes sense. It so simple I dont see why I didnt figure something like that out sooner LOL. Thanks again. Thats a BIG help.


Just Because Your Paranoid Doesn't Mean They Aren't After You...Because They Really Are

http://spearbang.awardspace.com/news.php
Re: Jumping troubles [Re: Ilidrake] #205623
05/07/08 16:47
05/07/08 16:47
Joined: Oct 2007
Posts: 116
S
sydan Offline
Member
sydan  Offline
Member
S

Joined: Oct 2007
Posts: 116
No problem in all honesty I started doing what you did and then I made a game with that, it didn't work I gave up forgot your method made a new game and worked this one out so yeah. Did you try to use the fps tutorial from acknex?


For some reason, my ambition always seems to beat my ability.
Re: Jumping troubles [Re: sydan] #205632
05/07/08 17:32
05/07/08 17:32
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Does anyone have the code for Grimber's FPS tutorial 1 or 2 from acknex?

I cant seem to get the jumping working from his code, are there any mistakes in what he has wrote?

Re: Jumping troubles [Re: DJBMASTER] #205654
05/07/08 19:38
05/07/08 19:38
Joined: Apr 2007
Posts: 249
Louisana, USA
Ilidrake Offline OP
Member
Ilidrake  Offline OP
Member

Joined: Apr 2007
Posts: 249
Louisana, USA
The code I posted is originally from the FPS tuts modified for side scrolling. The jumping code was the same though. But I wanted something smoother ya know so I started tweaking it and experimenting. DJMASTER if you'd like I can send the tuts to you. The code in them works for me.


Just Because Your Paranoid Doesn't Mean They Aren't After You...Because They Really Are

http://spearbang.awardspace.com/news.php
Re: Jumping troubles [Re: Ilidrake] #205656
05/07/08 20:01
05/07/08 20:01
Joined: Apr 2007
Posts: 249
Louisana, USA
Ilidrake Offline OP
Member
Ilidrake  Offline OP
Member

Joined: Apr 2007
Posts: 249
Louisana, USA
Well, I'm trying to implement your code but it aint working. The player shoots to the ceiling and then halls a$$ to the right. LOL!!!! its funny but not what I need.


Just Because Your Paranoid Doesn't Mean They Aren't After You...Because They Really Are

http://spearbang.awardspace.com/news.php
Re: Jumping troubles [Re: Ilidrake] #205659
05/07/08 20:17
05/07/08 20:17
Joined: Apr 2007
Posts: 249
Louisana, USA
Ilidrake Offline OP
Member
Ilidrake  Offline OP
Member

Joined: Apr 2007
Posts: 249
Louisana, USA
Got it working but now my player floats above the ground.


Just Because Your Paranoid Doesn't Mean They Aren't After You...Because They Really Are

http://spearbang.awardspace.com/news.php
Re: Jumping troubles [Re: Ilidrake] #205661
05/07/08 20:50
05/07/08 20:50
Joined: Apr 2007
Posts: 249
Louisana, USA
Ilidrake Offline OP
Member
Ilidrake  Offline OP
Member

Joined: Apr 2007
Posts: 249
Louisana, USA
figured it out! Thanks.


Just Because Your Paranoid Doesn't Mean They Aren't After You...Because They Really Are

http://spearbang.awardspace.com/news.php
Page 1 of 4 1 2 3 4

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