|
3rd person camera help
#247672
01/22/09 01:24
01/22/09 01:24
|
Joined: Jun 2007
Posts: 152 Norway
Darkyyes
OP
Member
|
OP
Member
Joined: Jun 2007
Posts: 152
Norway
|
there is 2 problems I am having EDIT: fixed problem with character floating 1: adding new moving functions 2: adding animation to the new functions when I add new movement and animation functions only maybe 2 of them work at the time what i have been trying to do is making forward and backwards playing seperate animations and key_a and key_d playing turn left and right animation
action player_code()
{
VECTOR temp[3];
VECTOR movement_speed[3]; // player's movement speed
var anim_percentage; // animation percentage
var jump_percentage; // animation percentage for jumping
var distance_to_ground; // the distance between player's origin and the ground
var jump_height;
var reached_height;
player = my; // I'm the player
while (1)
{
my.pan += 6 * (key_a - key_d) * time_step; // rotate the player using the "A" and "D" keys
vec_set (temp.x, my.x); // copy player's position to temp
temp.z -= 10000; // set temp.z 10000 quants below player's origin
distance_to_ground = c_trace (my.x, temp.x, IGNORE_ME | USE_BOX);
movement_speed.x = 5 * (key_w - key_s) * time_step; // move the player using "W" and "S"
movement_speed.y = 0; // don't move sideways
if (key_space && !reached_height)
{
jump_height = minv(40, jump_height + 5 * time_step); // 40 sets the height, 5 sets the ascending speed
if (jump_height == 40) // reached the maximum height? Then start descending!
{
reached_height = 1;
jump_height = maxv(0, jump_height - 5 * time_step); // 5 sets the falling speed
}
}
else // space isn't pressed anymore?
{
jump_height = maxv(0, jump_height - 3 * time_step); // use a smaller falling speed (3) for smaller jumps
if (!jump_height && !key_space) // the player has touched the ground?
{
reached_height = 0; // then allow it to jump again
}
}
movement_speed.z = -(distance_to_ground - 17) + jump_height; // 17 = experimental value
movement_speed.z = maxv(-35 * time_step, movement_speed.z); // 35 = falling speed
c_move (my, movement_speed.x, nullvector, GLIDE); // move the player
if (!jump_height) // the player isn't jumping?
{
if (!key_w && !key_s) // the player isn't moving?
{
ent_animate(my, "stand", anim_percentage, ANM_CYCLE); // play the "stand" animation
}
else // the player is moving?
{
ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // play the "walk" animation
}
anim_percentage += 5 * time_step; // 5 = animation speed
jump_percentage = 0; // always start jumping with the first frame
}
else // the player is jumping
{
jump_percentage += 5 * time_step; // 5 = jump animation speed
ent_animate(my, "jump", jump_percentage, ANM_CYCLE); // play the "jump" animation
}
// camera code
camera.x = player.x - 250 * cos(player.pan);
camera.y = player.y - 250 * sin(player.pan); // use the same value (250) here
camera.z = player.z + 150; // place the camera above the player, play with this value
camera.tilt = -20; // look down at the player
camera.pan = player.pan;
wait (1);
}
}
New to lite-c and gamestudio in general, thank you for reading. Com, A7 v7.7
|
|
|
Re: 3rd person camera help
[Re: Darkyyes]
#247707
01/22/09 08:34
01/22/09 08:34
|
Joined: Feb 2006
Posts: 385 Oldenburg,Germany
Ralph
Senior Member
|
Senior Member
Joined: Feb 2006
Posts: 385
Oldenburg,Germany
|
I doesnt know why you talk about any functions here. What you have to do is simple:
if (!key_w && !key_s) // the player isn't moving?
{
ent_animate(my, "stand", anim_percentage, ANM_CYCLE); // play the "stand" animation
}
else // the player is moving?
{
if(key_w){//w is pressing
ent_animate(my, "walkf", anim_percentage, ANM_CYCLE); // play the "walk" animation forwards
}
if(key_s){//s is pressing
ent_animate(my, "walkb", anim_percentage, ANM_CYCLE); // play the "walk" animation backwards
}
}
|
|
|
Re: 3rd person camera help
[Re: Ralph]
#247772
01/22/09 13:56
01/22/09 13:56
|
Joined: Jun 2007
Posts: 152 Norway
Darkyyes
OP
Member
|
OP
Member
Joined: Jun 2007
Posts: 152
Norway
|
I use the word function as the word ability to do something, sorry. and what if I want to add new animations to new keys and keep the old ones working? like a = turnleft and d = turnright? Thanks for your help though with problem 2 
Last edited by Darkyyes; 01/22/09 14:31.
New to lite-c and gamestudio in general, thank you for reading. Com, A7 v7.7
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|