Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 10:32
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip, Quad), 604 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
gravity depending on new_z #128361
05/06/07 15:07
05/06/07 15:07
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
I have a player that slows down when climbing steep slopes (trough gravity). Unfortunately the gravity also gets applied when the player walks sideways to the slope. Maybe this could be solved by comparing old_z with new_z (the altitude difference)...and when new_z has a higher value than old_z, gravity gets applied, if the new_z value is just slightly (or not) higher than new_z, no gravity gets applied. I'm just not able to bring this into c-script

Would be great, if someone could help

Re: gravity depending on new_z [Re: Loopix] #128362
05/06/07 15:21
05/06/07 15:21
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
If the player is a).moving sideways and b). also moving up,then realistically speaking,the code should apply gravity !

Re: gravity depending on new_z [Re: Loopix] #128363
05/06/07 15:23
05/06/07 15:23
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
If the player is moving sideways and also moving up,then relaistically speaking,the code should apply gravity !


I like good 'views' because they have no 'strings' attached..
Re: gravity depending on new_z [Re: zazang] #128364
05/06/07 15:39
05/06/07 15:39
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
sure...but I'm talking about the sort of gravity that makes one slow down when climbing slopes (exhaustment-gravity )...now it does this, but the side effect is the drifting when the player walkes sideways to the slope...it just doesent feel good

Here's the script so far...made by Slin (he's off right now...testing gravity on a horseback):

Code:
action explorer_code()
{
//set the skills to defaults if not changed
if(!my.PlayerSpeed_Move){my.PlayerSpeed_Move = 1.5;}
if(!my.PlayerSpeed_Turn){my.PlayerSpeed_Turn = 6;}
if(!my.PlayerSpeed_Run){my.PlayerSpeed_Run = 1;}
if(!my.PlayerClimbExperience){my.PlayerClimbExperience = 0.5;}
if(!my.PlayerClimbSteepness){my.PlayerClimbSteepness = 0.8;}
if(!my.PlayerJumpHeight){my.PlayerJumpHeight = 2;}

player_type = 3;
player = my;
shadow_stencil = on;
mat_shadow.alpha = 30;
my.shadow = on;
// my.scale_x = 0.5;
// my.scale_y = 0.5;
// my.scale_z = 0.5;
c_setminmax(me);

//Place the entity on the ground
my.z -= c_trace(my.x,vector(my.x,my.y,my.z-10000),use_box|ignore_me|ignore_passable|ignore_passents);

//get the height of the entitys origin
my.PlayerFootDist = 1;

while(1)
{

//Get the keyinput for the movement
my.PlayerInput_x = key_pressed(key_forward)-key_pressed(key_backward);
my.PlayerInput_x *= 1+key_pressed(key_run)*my.PlayerSpeed_Run;
my.PlayerInput_y = key_pressed(key_strafe_left)-key_pressed(key_strafe_right);

vec_set(my.PlayerMove_x,my.PlayerInput_x);
vec_scale(my.PlayerMove_x,time_step*my.PlayerSpeed_Move);

//Get the mousemovement for turning and rotate the entity
c_rotate(me,vector(mouse_force.x*time_step*-my.PlayerSpeed_Turn,0,0),glide|ignore_me|ignore_passable|ignore_passents);

//Gravity
my.PlayerMove_z = my.PlayerInput_z;
my.PlayerFloorDist = c_trace(my.x,vector(my.x,my.y,my.z-10000),use_box|ignore_me|ignore_passable|ignore_passents);
if(my.PlayerFloorDist > my.PlayerFootDist || my.PlayerMove_z > 0)
{
my.PlayerMove_z -= time_step*0.6;
}else
{
my.PlayerMove_z = 0;
}

//Jumping
if(my.PlayerFloorDist <= my.PlayerFootDist && key_pressed(key_jump))
{
my.PlayerMove_z = my.PlayerJumpHeight;
}

my.PlayerInput_z = my.PlayerMove_z;

//
if(((my.PlayerInput_x != 0 || my.PlayerInput_y != 0) && !my.PlayerMove_z) || normal.z < my.PlayerClimbSteepness)
{
my.PlayerGravity = -my.PlayerClimbExperience*1.5;
}else
{
my.PlayerGravity = 0;
}

//Move the player
c_move(me,my.PlayerMove_x,vector(0,0,my.PlayerGravity), glide + ignore_me|ignore_passable|ignore_passents);


player_camera();//calls the player camera function;
animate_states();

wait(1);
}
}



Last edited by Loopix; 05/06/07 15:43.
Re: gravity depending on new_z [Re: Loopix] #128365
05/06/07 17:03
05/06/07 17:03
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
hmm I see..I think I had faced a similar problem like this...but luckily I had a simple terrain wherein I stopped movements as soon as I was reaching the slope
with maximum Z..but yeah your case is slightly different


I like good 'views' because they have no 'strings' attached..
Re: gravity depending on new_z [Re: zazang] #128366
05/06/07 17:05
05/06/07 17:05
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Perhaps I might throw in some suggestons if you could give me a better vision of the problem. I'm not quite understanding the situation clearly.

The player is slowing down when going up a slope [which is good], but there's something wrong with moving sideways along slopes. Correct?


xXxGuitar511
- Programmer
Re: gravity depending on new_z [Re: xXxGuitar511] #128367
05/06/07 17:37
05/06/07 17:37
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
Yeah...kinda hard to explain

You know...when I face the slope and walk upwards, everything works fine...but when I walk, lets say, in an angle of 90' to the slope (still on the slope!), there are still forces shifting the player slightly downwards. I don't want that...could you understand?

Thanks for your efforts!

Re: gravity depending on new_z [Re: Loopix] #128368
05/06/07 17:46
05/06/07 17:46
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Ok. I understand now...
Hmm...


You could use the difference of the surface normal and the players direction to find out which angle he's facing [relative to the slope]. however, this would require converting the tilt/roll to pan angle...


xXxGuitar511
- Programmer
Re: gravity depending on new_z [Re: xXxGuitar511] #128369
05/06/07 17:52
05/06/07 17:52
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
Great! You might know that I'm completly brain dead when it comes to such mathematical vec_for_Idontknowwhat thingies Would be awesome if you could write down something into the script

Re: gravity depending on new_z [Re: Loopix] #128370
05/06/07 18:00
05/06/07 18:00
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
well I think this needs to be done here :-

1).find the vector which is parallel to the slope of the terrain and also exactly vertical.
2).now compare the sideways movement direction vector with the above vector..and accordingly adjust the gravity.

The trick is in finding the vector in step 1.Probably u have to use some inverse trignometric func on the normal.

Now even I want a solution to this


I like good 'views' because they have no 'strings' attached..
Page 1 of 2 1 2

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