1 registered members (tomaslolo),
1,542
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Script issue
#309465
02/09/10 15:31
02/09/10 15:31
|
Joined: Oct 2009
Posts: 60
Tman
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2009
Posts: 60
|
Hello forum, I am new here and was needing some help with code, first let me say this is a really good engine to work with. The issue that I am having is gravity for starters, I have the line commented out for jump because everytime I jump I just keep going, and second this may be an animation issue but I press a certain button to change states and it doesn't play the animation, any help would be appreciated thanks guys. Here is the code:
#include <acknex.h>
#include <default.c>
#define STATE skill1
#define ANIMATION skill2
#include "defines.c"
//#include "animation.c"
function camera_follow(ENTITY* ent)
{
while(1)
{
vec_set(camera.x,vector(-250,10,50)); // camera position relative to the player
vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
vec_add(camera.x,ent.x); // add player position
vec_set(camera.pan,vector(ent.pan,-10,0)); // look in player direction, slighty down
wait(1);
}
}
function ninja_move()
{
camera_follow(me);
VECTOR vFeet;
vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex
my.STATE = 0;
var walk_speed;
//walking with the sword in hand state
while(1)
{
VECTOR move_to_vector;
var distance_to_ground;
if(my.STATE == 0)
{
my.ANIMATION += 5 *time_step;
ent_animate(me,"idleSWA",my.ANIMATION,ANM_CYCLE);
if(key_cuu == 1)
{
ent_blend("runWS",0,15);
my.ANIMATION = 1;
my.STATE = 1;
}
/*
if(key_space == 1)
{
my.ANIMATION = 1;
my.STATE = 3;
}
*/
if(key_t == 1)
{
my.ANIMATION = 0;
my.STATE = 5;
}
}
if(my.STATE ==1)
{
//rotate player with the left and right keys
my.pan += (key_cul-key_cur)*5* time_step;
//move the entity forward
var distance = (key_cuu) * 5 *time_step;
c_move(me,vector(distance,0,0),NULL,GLIDE);
var rotateAround = (key_cud)* 5 * time_step;
c_rotate(me,vector(rotateAround,0,0),GLIDE);
//animate the player
my.ANIMATION += 2* distance;
ent_animate(me,"runWS",my.ANIMATION,ANM_CYCLE);
// adjust entity to the ground height, using a downwards trace
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = hit.z - vFeet.z; // always place player's feet on the ground
if(!key_cuu)
{
my.ANIMATION = 1;
my.STATE = 0;
}
}
/*
if(my.STATE == 3)
{
var gravity = 6;
my.z += 4 * gravity;
ent_animate(me,"jump",my.ANIMATION,0);
my.ANIMATION = 1;
}
*/
if(my.STATE == 4)
{
my.ANIMATION += 5 *time_step;
ent_animate(me,"idleSWI",my.ANIMATION,ANM_CYCLE);
}
if(my.STATE == 5)
{
ent_animate(me,"takeSWO",my.ANIMATION,0);
my.STATE = 4;
}
if((my.STATE == 4) && key_cuu == 1)
{
//rotate player with the left and right keys
my.pan += (key_cul-key_cur)*5* time_step;
//move the entity forward
var distance = (key_cuu) * 5 *time_step;
c_move(me,vector(distance,0,0),NULL,GLIDE);
var rotateAround = (key_cud)* 5 * time_step;
c_rotate(me,vector(rotateAround,0,0),GLIDE);
//animate the player
my.ANIMATION += 2* distance;
ent_animate(me,"run",my.ANIMATION,ANM_CYCLE);
// adjust entity to the ground height, using a downwards trace
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = hit.z - vFeet.z; // always place player's feet on the ground
if(!key_cuu)
{
my.ANIMATION = 1;
my.STATE = 0;
}
}
wait(1);
}
}
Last edited by Tman; 02/09/10 16:25.
|
|
|
Re: Script issue
[Re: Tman]
#309497
02/09/10 19:25
02/09/10 19:25
|
Joined: Sep 2009
Posts: 993 Budapest
Aku_Aku
User
|
User
Joined: Sep 2009
Posts: 993
Budapest
|
Maybe this stuff will help you, to know better the movement with this engine: KHMovement discussion You can download the original document at the Free Resources search for KHMovement or KH_Movement. Also you can found more topics here that cover this problem.
|
|
|
Re: Script issue
[Re: Gamesaint762]
#309516
02/09/10 20:33
02/09/10 20:33
|
Joined: Sep 2009
Posts: 993 Budapest
Aku_Aku
User
|
User
Joined: Sep 2009
Posts: 993
Budapest
|
I read the KH_Movement document and it contains a chapter of gravity and jump. But i can imagine the starter of the thread wants another approach of moving.
Last edited by Aku_Aku; 02/09/10 20:35.
|
|
|
Re: Script issue
[Re: Tman]
#309648
02/10/10 15:25
02/10/10 15:25
|
Joined: Oct 2009
Posts: 60
Tman
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2009
Posts: 60
|
Ok now I have broken down my script and tyring to get just the blend function to work when he starts and stops moving, can anyone help me with this?
//walking withOut the sword in hand state
while(1)
{
//default state
if(my.STATE == 0)
{
//rotate player with the left and right keys
my.pan += (key_cul-key_cur)*5* time_step;
my.ANIMATION += 2 *time_step;
ent_animate(me,"idleSWA",my.ANIMATION,ANM_CYCLE);
}
//the run state without the sword in hand
if(my.STATE ==1)
{
//rotate player with the left and right keys
my.pan += (key_cul-key_cur)*5* time_step;
//move the entity forward
var distance = 25 *time_step;
c_move(me,vector(distance,0,0),NULL,GLIDE);
ent_blend("runWS",25,45);
//animate the player
my.ANIMATION += 15 * time_step;
ent_animate(me,"runWS",my.ANIMATION,ANM_CYCLE);
// adjust entity to the ground height, using a downwards trace
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = hit.z - vFeet.z; // always place player's feet on the ground
}
if((key_cuu == 1)&& my.STATE == 0)
{
my.ANIMATION = 0;
my.STATE = 1;
}
else if((!key_cuu)&& my.STATE == 1)
{
if(my.ANIMATION > 100)
{
ent_blend("idleSWA",5.5,50);
}
my.STATE = 0;
}
It just seem not to blend correctly.
Last edited by Tman; 02/10/10 16:29.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|