crouching

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

crouching

Post by darksmaster923 »

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.
Juryiel
Posts: 103
Joined: Fri Jan 04, 2008 1:18 pm

Re: crouching

Post by Juryiel »

Can't you just make a set of crouching animations and move the camera down a bit?
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: crouching

Post by darksmaster923 »

i use attach camera, dunno how to move it
Herp derp.
Juryiel
Posts: 103
Joined: Fri Jan 04, 2008 1:18 pm

Re: crouching

Post by Juryiel »

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.
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: crouching

Post by darksmaster923 »

attach camera to bone makes it all weird and with the pawn i cant move
Herp derp.
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: crouching

Post by darksmaster923 »

bump
sorry but i need to know. anything will be helpful, designs etc
Herp derp.
User avatar
federico
RF Dev Team
Posts: 443
Joined: Tue Jul 05, 2005 3:14 pm
Contact:

Re: crouching

Post by federico »

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.
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: crouching

Post by darksmaster923 »

ive tried that but i cant seem to move and i start out on the ground
Herp derp.
User avatar
federico
RF Dev Team
Posts: 443
Joined: Tue Jul 05, 2005 3:14 pm
Contact:

Re: crouching

Post by federico »

ive tried that but i cant seem to move and i start out on the ground
Let's get this thing done using some methods, for example post some code.

I use a code like this:

Code: Select all

SetNoCollision();
PawnRender(false);
AttachCamera();

PositionToPawn("PLAYER_ENTITY", X_POS, Y_POS, 0, true);
where Y_POS is the height of the third person camera. in camera.ini i use these settings:

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
The camera pawn is the proj.act:

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 can understand why you are stuck on the ground, but I can't see why you cannot move.
I hope this could help. :wink:
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: crouching

Post by darksmaster923 »

still doesnt work. just to say i have disabled and deleted a characters.

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);
	} ]

}
my player script

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.
User avatar
federico
RF Dev Team
Posts: 443
Joined: Tue Jul 05, 2005 3:14 pm
Contact:

Re: crouching

Post by federico »

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:

Code: Select all

 self.ideal_pitch = self.camera_pitch;
      ChangePitch();
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:

Code: Select all

self.ThinkTime = 0;
      
Why you would need it?

Add:

Code: Select all

yaw_speed= 400;
to

Code: Select all

self.ideal_yaw = self.player_yaw;
             ChangeYaw(); 
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):

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);
(I didn't test this code, correct the errors if any)
Pressing '8' and '9' is your camera height affected?
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: crouching

Post by darksmaster923 »

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.
User avatar
federico
RF Dev Team
Posts: 443
Joined: Tue Jul 05, 2005 3:14 pm
Contact:

Re: crouching

Post by federico »

I think that your troubles are in the camera.ini

Code: Select all

[ThirdPerson]
allowzoom = true
mouserotation = true
allowlook = true
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...
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: crouching

Post by darksmaster923 »

aw it still doesnt work :(

EDIT
oh never mind it works

added this in setup order
self.yaw_speed = 10000;
Herp derp.
User avatar
paradoxnj
RF2 Dev Team
Posts: 1328
Joined: Wed Mar 01, 2006 7:37 pm
Location: Brick, NJ
Contact:

Re: crouching

Post by paradoxnj »

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....
Post Reply