When attach the gun to the player's hand, it work. The problem is I cant move when i try to walk tothe right, where the gun is. There is the action script ;
action gun()
{
set(my,PASSABLE);
while(1)
{
vec_for_vertex (my.skill1, you, 244);
vec_diff (NULL, my.skill1, my.skill1);
vec_to_angle (my.pan, my.skill1);
vec_set (my.x, my.skill1);
my.pan=your.pan;
wait(1);
}
and there is the hole script;
///////////////////////////////
#include <acknex.h>
#include <default.c>
#define CREATOR skill1
#define ANIMATION skill2
#define STATE skill3
///////////////////////////////
function main()
{
video_screen = 7;
screen_size.x = 1600;
screen_size.y = 900;
level_load("shooter.wmb");
}
function camera_follow(ENTITY* ent)
{
while(1)
{
vec_set(camera.x,vector(camera.tilt-100,10,28));
vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
vec_add(camera.x,ent.x);
//camera.y +=NULL ;
camera.pan =ent.pan;
//camera.tilt += ent.tilt;
camera.tilt += ( mouse_force.y) ;
wait(1);
}
}
action gun()
{
set(my,PASSABLE);
while(1)
{
vec_for_vertex (my.skill1, you, 244);
vec_diff (NULL, my.skill1, my.skill1);
vec_to_angle (my.pan, my.skill1);
vec_set (my.x, my.skill1);
my.pan=your.pan;
wait(1);
}
}
action man_walk()
{
camera_follow(me);
my.emask |= ENABLE_IMPACT;
VECTOR vFeet;
vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex
// set FLAG2 to make the wizard detectable by c_scan,
// and store the wizard pointer in its own CREATOR skill
// in case the wizard is detected directly
set(my,FLAG2);
my.CREATOR = me;
my.STATE = 1;
while (1)
{
// state 1: walking ////////////////////////////////////////////
if (my.STATE == 1)
{
// rotate the entity with the arrow keys
my.pan -= (mouse_force.x)*5*time_step;
// my.tilt += mouse_force.y;
// move the entity forward/backward with the arrow keys
var distance = (key_w-key_s)*5*time_step;
c_move(me, vector(distance,0,0), NULL, GLIDE);
var distance2= (key_a-key_d)*5*time_step;
c_move(me, vector(0,distance2,0), NULL, GLIDE);
// animate the entity
my.ANIMATION += 2*distance;
ent_animate(me,"walk",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_space) { // key pressed -> go to state 2
my.ANIMATION = 0;
my.STATE = 2;
}
}
// state 2: casting a spell ///////////////////////////////////
if (my.STATE == 2)
{
my.ANIMATION += 8*time_step;
ent_animate(me,"attack",my.ANIMATION,0);
if (my.ANIMATION > 100) { // create the spell and go to state 3
ent_create("pistol.mdl",vector(my.x,my.y,my.z),gun );
my.STATE = 1;
}
}
// state 3: waiting for key release ///////////////////////////
if (my.STATE == 3) {
if (!key_space) my.STATE = 1; // when key was released, back to state 1
}
wait(1);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
By the way, I based this on the litec workshop 24 and I use the A7 version.
Can you help me please?