crouching
Posted: Mon Feb 11, 2008 4:33 am
hey how do i make crouching into a scripted player? cuz i cant seem to get it to work. i tried creating a different pawn and attaching it to the player pawn but then i cant move. any ideas>
Let's get this thing done using some methods, for example post some code.ive tried that but i cant seem to move and i start out on the ground
Code: Select all
SetNoCollision();
PawnRender(false);
AttachCamera();
PositionToPawn("PLAYER_ENTITY", X_POS, Y_POS, 0, true);
Code: Select all
[ThirdPerson]
; camera height above ground (in texels)
; auto adjusts height to current player actor
height = 0
; angle (in degrees) of camera above horizontal
angleup = 40
; distance (in texels) of camera from player
distance = 90
; true if mouse look up/down is allowed
allowlook = true
; true if camera can be zoomed in/out
allowzoom = true
mouserotation = true
; closest distance you can zoom in to
minimumdistance = 10
; maximum distance you can zoom out to
maximumdistance = 1024
Code: Select all
[camera]
actorname = Projectile/proj.act
actorrotation = 0 180 0
actorscale = 1
fillcolor = 255 255 255
ambientcolor = 255 255 255
subjecttogravity = false
boundingboxanimation = nocollide
shadowsize = 0
Code: Select all
{
Spawn[ ()
{
Console(true);
LowLevel("setup");
} ]
setup[ ()
{
SetNoCollision();
PawnRender(false);
AttachCamera();
self.think = "idle";
} ]
idle[ ()
{
self.ThinkTime = 0;
self.ideal_yaw = self.player_yaw;
ChangeYaw();
self.ideal_pitch = self.camera_pitch;
ChangePitch();
PositionToPawn("player", 0, 75, 0, true);
} ]
}
Code: Select all
{
MOVESPEED [300]
JUMPFORCEUP [50]
JUMPSPEED [30]
CROUCH [false]
WALK [false]
STAND [stand]
CROUCH [crouch]
HEALTH [hp]
HP [100]
walk [false]
Spawn[()
{
Console(true);
AttributeOrder(HEALTH,HP,"Die");
BoxWidth(20);
StepHeight(10);
FadeOut(0.01,0);
HideFromRadar(true);
LowLevel("setup");
} ]
setup[()
{
self.ThinkTime = 0.1;
PawnRender(true);
PlayerRender(false);
self.yaw_speed = 10000;
self.think = "loop";
} ]
loop[()
{
self.ThinkTime = 0;
//AttachCameraToBone("head");
movement();
//handlecamera();
} ]
movement[ ()
{
keys();
if(IsKeyDown(25))
{
MOVESPEED = 150;
SetEventState("crouch",true);
}
else
{
MOVESPEED = 300;
SetEventState("crouch",false);
}
if(IsKeyDown(46))
{
ForceUp(JUMPFORCEUP);
}
if(IsKeyDown(26)) //if not, see if a movement key is pressed and move to that direction
{
walkmove(self.current_yaw+1.570796327,MOVESPEED);
if(self.IsFalling = false)
{
if(walk = false and GetEventState("walk") = false)
{
PlaySound("footsteps/footstep.wav");
walk = true;
}
}
}
if(IsKeyDown(28))
{
walkmove(self.current_yaw-1.570796327,MOVESPEED);
if(self.IsFalling = false)
{
if(walk = false and GetEventState("walk") = false)
{
PlaySound("footsteps/footstep.wav");
walk = true;
}
}
}
if(IsKeyDown(15))
{
walkmove(self.current_yaw,MOVESPEED);
if(self.IsFalling = false)
{
if(walk = false and GetEventState("walk") = false)
{
PlaySound("footsteps/footstep.wav");
walk = true;
}
}
}
else
{
if(IsKeyDown(27))
{
walkmove(self.current_yaw+3.141592654,MOVESPEED);
if(self.IsFalling = false)
{
if(walk = false and GetEventState("walk") = false)
{
PlaySound("footsteps/footstep.wav");
walk = true;
}
}
}
}
} ]
handlecamera[ ()
{
self.ideal_yaw = self.player_yaw; //rotate with mouse movement
ChangeYaw();
} ]
keys[ ()
{
if(walk = true)
{
walk = false;
}
} ]
Die[ ()
{
LowLevel("death");
} ]
death[ ()
{
FillScreenArea(1, true, 255, 255, 20, 50);
PlaySound("die1.wav");
HighLevel("remove");
} ]
remove[ ()
{
Remove(true);
} ]
}
Code: Select all
self.ideal_pitch = self.camera_pitch;
ChangePitch();
Code: Select all
self.ThinkTime = 0;
Code: Select all
yaw_speed= 400;
Code: Select all
self.ideal_yaw = self.player_yaw;
ChangeYaw();
Code: Select all
if( IsKeyDown(8) )
{
Y_POS = Y_POS-1;
}
if( IsKeyDown(9) )
{
Y_POS = Y_POS+1;
}
debug("Y_POS:" # Y_POS);
PositionToPawn("player", 0, Y_POS, 0, true);
Code: Select all
[ThirdPerson]
allowzoom = true
mouserotation = true
allowlook = true