crouching
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
crouching
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>
Herp derp.
Re: crouching
Can't you just make a set of crouching animations and move the camera down a bit?
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
Re: crouching
What's it attached to? If it's attached to a separate 'camera' pawn you can offset it by a certain amount in the PositionToPawn (or whichever of those commands you're using).
You can also use AttachCameraToEntity to attach the camera to your pawn at a specified bone. If you attach it to a bone that lowers in the crouching animation it should lower when the crouching animation is playing. I'm just guessing here since I've never tried it.
You can also use AttachCameraToEntity to attach the camera to your pawn at a specified bone. If you attach it to a bone that lowers in the crouching animation it should lower when the crouching animation is playing. I'm just guessing here since I've never tried it.
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
Re: crouching
My advice is to attach another pawn to the scripted player (using PositionToPawn), then attach the third person camera to the camera pawn using simply AttachCamera();
Set the camera height in camera.ini to 0. Offsetting the camera pawn position (see PositionToPawn) you can control the camera height and offset.
I know that to use another pawn doesn't sound an optimization. Actually I created a script command just to do this job, but I prefer to use another pawn to have complete control over the camera movements.
Set the camera height in camera.ini to 0. Offsetting the camera pawn position (see PositionToPawn) you can control the camera height and offset.
I know that to use another pawn doesn't sound an optimization. Actually I created a script command just to do this job, but I prefer to use another pawn to have complete control over the camera movements.
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
Re: crouching
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
I use a code like this:
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
I hope this could help.

- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
Re: crouching
still doesnt work. just to say i have disabled and deleted a characters.
my camera script
my player script
my camera script
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);
} ]
}
Herp derp.
Re: crouching
so let's start from the camera problem, next we will move to the movements.
I assume:
- Your camera is third person.
and that your troubles are:
- your camera is on the ground
- your camera doesn't tilt nor rotate.
You don't need:
the third person camera doesn't change the pitch in this way. You could use a first person camera but you will have to use the TiltCamera command. The ChangePitch method could be useful using a fixed camera attached to the camera pawn. But in this case you are using a thirdperson camera so you should delete it because you simply control the pitch using the mouse.
Delete:
Why you would need it?
Add:
to
Just a precaution...
Then, is you camera height set to zero in the camera.ini (ThirdPerson section)?
Modify the last part of your script (add an Y_POS variable at the beginning):
(I didn't test this code, correct the errors if any)
Pressing '8' and '9' is your camera height affected?
I assume:
- Your camera is third person.
and that your troubles are:
- your camera is on the ground
- your camera doesn't tilt nor rotate.
You don't need:
Code: Select all
self.ideal_pitch = self.camera_pitch;
ChangePitch();
Delete:
Code: Select all
self.ThinkTime = 0;
Add:
Code: Select all
yaw_speed= 400;
Code: Select all
self.ideal_yaw = self.player_yaw;
ChangeYaw();
Then, is you camera height set to zero in the camera.ini (ThirdPerson section)?
Modify the last part of your script (add an Y_POS variable at the beginning):
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);
Pressing '8' and '9' is your camera height affected?
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
Re: crouching
sorry i did a stupid mistake and forgot to give the player an entity name. sorry. but for some reason i cant turn left or right anymore
Herp derp.
Re: crouching
I think that your troubles are in the camera.ini
The current RF release is buggy on this topic. You can have the zoom or the mouserotation but not both. So be careful setting up the camera. I simply added a new command in low_level script: self.camera_yaw, but you can do it without modifying the source...
Code: Select all
[ThirdPerson]
allowzoom = true
mouserotation = true
allowlook = true
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
Re: crouching
aw it still doesnt work 
EDIT
oh never mind it works
added this in setup order
self.yaw_speed = 10000;

EDIT
oh never mind it works
added this in setup order
self.yaw_speed = 10000;
Herp derp.
Re: crouching
This should be added to the FAQ. I'm sure other people will want crouching in their game. 

Many Bothans died to bring you this signature....