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
3 registered members (AndrewAMD, TipmyPip, OptimusPrime), 15,359 guests, and 7 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
My Movement WDL has an error help. #12101
03/15/03 00:56
03/15/03 00:56
Joined: Nov 2002
Posts: 1,342
WizRealm Offline OP
Expert
WizRealm  Offline OP
Expert

Joined: Nov 2002
Posts: 1,342
Ok I am making my own scripts. And in 3rd person view my model's legs go through the floor. Also the camera tilts too much the right and left to much when you turn in 3rd person. Ok here's my code.

code:
 

////////////////////////////////////////////////////////////////////////////
//Defines

//Pointers
Entity* MainChar;

//Variables

Var B; //misc variable stores infomation that isn't needed for long

Var Player_Move_State = 0; // 0 - Standing, 1 - Walking, 2 - Falling

Var Cam_Mode = 0; // 0 - First Person, 1 - 3rd Person

Var Cam_Tilt = -30; // Camera tilt in 3rd person view

Var First_Cam_Tilt = 0; // Camera tilt in 1st person view set by the player

Var Max_Cam_Tilt_Up = 70; // How far the camera can tilt in 1st person view

Var Max_Cam_Tilt_Down = -70;

Var EyeHeight = 10;

//Vectors

Var Cam_Dist[3]; //Distance away from player in 3rd person view

Var force[3];
Var dist[3];
Var Friction;
////////////////////////////////////////////////////////////////////////////
Function ToggleCamMode()
{

If(Cam_Mode == 0) // If camera mode is first person change to 3rd person
{
Cam_Mode = 1;
}
Else // If camera mode is 3rd person change to first person
{
Cam_Mode = 0;
}
}
////////////////////////////////////////////////////////////////////////////
Function Increase_Cam_Tilt()
{

If (First_Cam_Tilt < Max_Cam_Tilt_Up)
{
First_Cam_Tilt += 5;
}

}
////////////////////////////////////////////////////////////////////////////
Function Decrease_Cam_Tilt()
{

If (First_Cam_Tilt > Max_Cam_Tilt_Down)
{
First_Cam_Tilt -= 5;
}

}
////////////////////////////////////////////////////////////////////////////
Function Reset_Cam_Tilt()
{

First_Cam_Tilt = 0;

}
////////////////////////////////////////////////////////////////////////////
Function SmartCam()
{

Cam_Dist.x = 100;
Cam_Dist.y = 100;
Cam_Dist.z = 100;

While(Cam_Mode == 0)
{
Camera.Genius = MainChar;
Camera.X = MainChar.x;
Camera.Y = MainChar.y;
Camera.Z = MainChar.z + EyeHeight; //player.min_z;
Camera.pan = MainChar.Pan;
Camera.tilt = 0 + First_Cam_Tilt;
wait(1);
}

While(Cam_Mode == 1)
{
Camera.Genius = Null;
Camera.X = MainChar.x + Cam_Dist.x;
Camera.Y = MainChar.y + Cam_Dist.y;
Camera.Z = MainChar.z + Cam_Dist.z; //player.min_z
Camera.pan = MainChar.Pan;
Camera.tilt = Cam_Tilt;
wait(1);
}

}
////////////////////////////////////////////////////////////////////////////
Action Player_Walk
{
MainChar = Me;

while(1)
{
force.pan = -10 * key_force.x;
my.skill14 = time*force.pan + max(1-time*0.7,0)*my.skill14;
my.pan += time * my.skill14;

vec_set(temp,my.x);
temp.z -= 4000;
trace_mode = ignore_me+ignore_sprites+ignore_models+use_box;
result = trace(my.x,temp);
if (result > 5) //Player in the air?
{
force.x = 0;
force.y = 0;
force.z = -5; //gravity force
friction = 0.1; //air friction
}
else //on or near ground
{
force.x = 10 * key_force.y;
force.y = 0;
friction = 0.7; //ground friction
}

my.skill11 = time*force.x + max(1-time*friction,0)*my.skill11;
my.skill13 = time*force.z + max(1-time*friction,0)*my.skill13;
dist.x = time * my.skill11; // distance ahead
dist.y = 0;
dist.z = time * my.skill13; // distance down
move_mode = ignore_passable + glide;
b = ent_move(dist,nullvector); // move the player

If (b != 0) //Player is moving find out why
{
If (key_force.x != 0) //Player is using the arrow keys to move
{
Player_Move_State = 1; //Player is walking
}

If (key_force.y != 0) //Player is using the arrow keys to move
{
Player_Move_State = 1; //Player is walking
}

Else //Player isn't using the arrow keys so the player must be falling
{
Player_Move_State = 2; //Player is falling
}

}

If (b == 0) //Player is standing still
{
Player_Move_State = 0;
}

Player_Animation(); //Animate character
SmartCam();
wait(1);
}
}
////////////////////////////////////////////////////////////////////////////
Function Player_Animation()
{
//If player is walking make the model go though walking animation
While(Player_Move_State == 1)
{
ent_cycle("walk", my.skill20);
my.skill20 += 1 * time;

If (my.skill20 > 100)
{
my.skill20 = 0;
ent_playsound (me, thud, SoundFXVolume); //Play step sound
}

wait(1);
}
}
////////////////////////////////////////////////////////////////////////////
On_home Reset_Cam_Tilt;
On_pgup Increase_Cam_Tilt;
On_pgdn Decrease_Cam_Tilt;
On_tab ToggleCamMode;
////////////////////////////////////////////////////////////////////////////



Re: My Movement WDL has an error help. #12102
03/18/03 08:10
03/18/03 08:10
Joined: Feb 2003
Posts: 1,036
Chicago Area, U.S.A.
D
Digital Dave Offline
Expert
Digital Dave  Offline
Expert
D

Joined: Feb 2003
Posts: 1,036
Chicago Area, U.S.A.
I see no bounding box definition. Look up Chris Robertson's (aka mudhole) collision tutorial in user contributions.....

Re: My Movement WDL has an error help. #12103
03/20/03 05:13
03/20/03 05:13
Joined: Nov 2002
Posts: 1,342
WizRealm Offline OP
Expert
WizRealm  Offline OP
Expert

Joined: Nov 2002
Posts: 1,342
Thanks for the help.


Moderated by  HeelX, Spirit 

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