Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 3 1 2 3
Re: I am getting close......... [Re: ] #223879
08/27/08 01:36
08/27/08 01:36
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline
Serious User
Blade280891  Offline
Serious User

Joined: Jan 2008
Posts: 1,580
cemetarycat ,you are blowing this way out of proportion , and i wasnt acting like a mod or being pushy.


My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Re: I am getting close......... [Re: Blade280891] #223881
08/27/08 01:43
08/27/08 01:43

C
cemetarycat
Unregistered
cemetarycat
Unregistered
C




haha. smile

Halo Regenerative Flame Shields On to Max.

Re: I am getting close......... [Re: ] #223939
08/27/08 18:58
08/27/08 18:58
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
here some code I found to movement of a object.

It may be in A6, seeing I am not up tp par yet with this program.
renny

Code:

ok, let´s see

what do we need to script a player-script?
- c_rotate (to rotate the player)
- c_move (to move the player)
- the WASD-keys (or other - a control for the user)
- ent_cycle (to animate our model): optional
- gravity
- a jump code



how to calculate the movement
Code:
--------------------------------------------------------------------------------

(key_w-key_s)*speed_factor*time+joy_force.y*time;
--------------------------------------------------------------------------------

if w or s is pressed calculate the speed. speed_factor can be rise if the player is to slow. the "time"-factor 

make it suitable for different FPS (because the player would be slower or faster on different PCs). store the 

calculated var in an temporary array (i.e. movement.x)
do the same with the sided movement (a and d)


how to rotate
do it like above to calculate the rotation (pan) of the player and store it in an array (i.e. rotation.x)


how to animate
if the movement is > 0 the player should "walk". so check the var where you have stored the calculated 

movement if it´s greater than zero. if yes play the animation:
Code:
--------------------------------------------------------------------------------

if(movement.x>0)&&(!player.flag1) //if flag1 is activated the animation would not be 

played.{ent_cycle("walk", player.animation);player.animation -= 8*time;player.animation %=100;}
--------------------------------------------------------------------------------

don´t forget to create an animation for standing too (if the movement == 0)


how to add gravity
at first you have to trace down (to check if the player is not on the bottom). so create an array, copy the 

player position (vec_set), but substract 1000 or more quants from the array. now trace (with c_trace) down
Code:
--------------------------------------------------------------------------------

c_trace(player.x, temp,ignore_me  + use_box + ignore_passable);
--------------------------------------------------------------------------------
and store the result in a var (i.e. grddist). then check if the var is greater than 1. if yes, the player isn´t on 

the bottom, so he has to fall. so substract from the movement.z a value (the greater, the faster the player 

fall) and multiply with time
if the player is already on the floor, set the movement.z to 0!! otherwise he would not stop to fall


how to jump
the player have to move up with an excreasing (the oposite of increasing  ) value.
Code:
--------------------------------------------------------------------------------

while (jump > -1)	{		movement.z = 18 * time * jump;		jump -= 0.09 * time; 

		if( grddist < 5){jump = 1;break;}		wait (1);	}jump=1;
--------------------------------------------------------------------------------
the player moves with an excreasing speed up. the value turn to a negative var till -1 or the bottom is 

reached. then the player stop to "fall" and the var will be resetted.
to make it independend from the player-code write it in another function


how to structure a player-script
it´s really simple. at first you have to calculate the needed vars. then, if you want, the jump-code, and at 

least the executing. note: we have just CALCULATED all required values. but the player won´t move if we 

don´t execute it. this can we do with c_move and c_rotate. c_move has a collision-system, so we can´t go 

through walls. and so should (or can) your player code looks:

Code:
--------------------------------------------------------------------------------

action player{player=my;while(player==my){//calcutlaing movement//calculating rotation//calculating 

gravity//play animation//EXECUTE!if(key_space){jump();} //if space was hit, 

jump!c_rotate(player,your_angle_array,ignore_passable+glide); 

//rotate!c_move(player,movement.x,nullvector,ignore_passable+glide); //move!cam_pos(); //place the camera 

on it´s new position!wait(1);}}
--------------------------------------------------------------------------------









the camera
write a new function that places the camera (cam_pos() or so).

that the camera is turning around the player (in a circle!) if he rotate, you can calculate the position with 

sin() and cos(). so you can calculate the camera.x-position:
Code:
--------------------------------------------------------------------------------

camera.x = player.x - offset * cos(player.pan);
--------------------------------------------------------------------------------
offset is the radius between the player and the cam. calculate the camera.y too and define the height of 

the cam:Code:
--------------------------------------------------------------------------------

camera.z = player.z + cam_height;
--------------------------------------------------------------------------------
cam_height is the height-offset to the player-height and the camera-height.
but oh! the camera doesn´t look in the player-direction! change it by set the camera.pan with the 

player.pan equal 
note: the cam_pos will be executed every frame (in the playercode) so DON´T add in the cam_pos a while!


i hope it could help

Regards




I'd put the cam_pos(); after the c_move





I have A7 Commercial .............. Now I just need to learn how to use it

Page 3 of 3 1 2 3

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

Gamestudio download | 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