Help! scriptpawn for platform game

Topics regarding Scripting with Reality Factory
Post Reply
Aaron87
Posts: 7
Joined: Mon Oct 18, 2010 5:23 am

Help! scriptpawn for platform game

Post by Aaron87 » Fri Nov 05, 2010 4:19 am

Greetings to the community.

I've been learning for some time to use the scripts and came to a problem that is difficult to fix me, because I'm not very good with this.

I'm trying to make a player script that Abanse, turn to walk back and jump, just like a platform game (mario bros, Castelvania.). so far I have this:

Code: Select all

{

//Variables declaradas

DIR[0]
VEL[0]
ANC[0]
FuerzaSalto[0]
VELSALTO[0]


//Orden INICIO


	Inicio[()
	{
	Console(true);
	SetAttribute("salud", 100, "Jugador");
	AttributeOrder("salud", 100, "Muere");
	SetGroup("Smash");
	LowLevel("Normal");
	}]


//Orden NORMAL

	Normal[()
	{
	walkmove(self.current_yaw+DIR, VEL);
	self.yaw_speed=9999;
	ChangeYaw();
	PlayerRender(false);
		
		if(IsKeyDown(26))
		{
		
		if(ANC="Walk")
		{
		if(self.animate_at_end)
		{
		Animate("Walk");
		}
		ChangeYaw();
		DIR= ConvertDegrees(0);
		VEL=70;
		}
		else
		{
		ANC="Walk";
		AnimateBlend("Walk",0.5);
		ChangePitch(self.ideal_pitch=180);
		DIR=ConvertDegrees(0);
		VEL=70;
		}

//Movimiento ATRAS

		}
		if(IsKeyDown(28))
		{
		if(ANC="Walk")
		{
		if(self.animate_at_end)
		{
		Animate("Walk");
		}
		ChangeYaw();
		DIR= ConvertDegrees(180);
		VEL=70;
		}
		else
		{
		ANC="Walk";
		AnimateBlend("Walk",0.5);
		ChangeYaw();
		DIR=ConvertDegrees(180);
		VEL=70;
		}

		}

if(((IsKeyDown(15))=false)and((IsKeyDown(26))=false)and
((IsKeyDown(27))=false)and((IsKeyDown(28))=false))
{
		if(ANC="Idle")
		{
		if(self.animate_at_end)
		{
		Animate("Idle");
		}
		DIR=0;
		VEL=0;
		}
		else
		{
		ANC="Idle";
		AnimateBlend("Idle",0.5);
		}
		DIR=0;
		VEL=0;
		}

}

}]

}

		if(IsKeyDown(26))
		{
		if(ANC="Walk")
		{
		if(self.animate_at_end)
		{
		Animate("Walk");
		}
		VEL=70;
		DIR=0;
		}
		else
		{
		ANC="Walk";
		AnimateBlend("Walk",0.5);
		
		VEL=70;
		DIR=0;
		}

well, I can miss a lot to make it what I want, so any help is welcome.

Image

http://img186.imageshack.us/img186/3305/frontbackq.jpg

But this script only allows the character to walk forward and walk back, but does not turn back.

I have trouble understanding how to do this. thank you very much in advance that I want to help.

"Hasta la vista!"

User avatar
paradoxnj
RF2 Dev Team
Posts: 1328
Joined: Wed Mar 01, 2006 7:37 pm
Location: Brick, NJ
Contact:

Re: Help! scriptpawn for platform game

Post by paradoxnj » Sun Nov 07, 2010 9:17 pm

You need to rotate the model 180 degrees and walk forward to simulate the walking style you want. Steps should be as follows:

-- Create a variable to store the current state of the actor (e.g walk_left, walk_right). This can be a global variable or an attribute.

-- If the actor is walking left and the right button is pressed, you need to rotate the actor 180 degrees, then switch the state to walk_right.

Same steps for left.
Many Bothans died to bring you this signature....

Aaron87
Posts: 7
Joined: Mon Oct 18, 2010 5:23 am

Re: Help! scriptpawn for platform game

Post by Aaron87 » Thu Nov 11, 2010 3:03 am

Thanks, paradoxnj.

but i' resolved the very next day the script.

What's more, it attached here for anyone to use.
this is for the character to walk forward, turn and walk back, down, normal jump and double jump.

Code: Select all

{

//Variables declaradas

DIR[0]
VEL[0]
ANC[0]
VELSALTO[0]
DERECHA[0]
IZQUIERDA[0]


//Orden INICIO


	Inicio[()
	{
	Console(true);
	SetAttribute("salud", 100, "Jugador");
	AttributeOrder("salud", 100, "Muere");
	SetGroup("Smash");
	LowLevel("Movimientos");
	}]


//Orden de MOVIMIENTOS

	Movimientos[()
	{
	walkmove(self.current_yaw+DIR, VEL);
	self.yaw_speed=9999;
	ChangeYaw();
	PlayerRender(false);

		if(self.IsFalling=true)
		{
		self.think="Caida";
		}
		else
		{
		if(IsKeyDown(15))
		{
		self.think="InicioSalto";
		}
		

//Movimiento IZQUIERDA

		if(IsKeyDown(26))
		{
		if(IsKeyDown(36))
		{
		if(ANC="Run")
		{
		if(self.animate_at_end)
		{
		Animate("Run");
		}
		self.ideal_yaw= ConvertDegrees(0);
		VEL=150;
		VELSALTO=150;
		DIR=0;
		}
		else
		{
		ANC="Run";
		AnimateBlend("Run",0.2);
		VEL=150;
		VELSALTO=150;
		DIR=0;
		}
		}
		else
		{
		if(ANC="Walk")
		{
		if(self.animate_at_end)
		{
		Animate("Walk");
		}
		self.ideal_yaw= ConvertDegrees(0);
		VEL=80;
		VELSALTO=80;
		DIR=0;
		}
		else
		{
		ANC="Walk";
		AnimateBlend("Walk",0.2);
		self.ideal_yaw= ConvertDegrees(0);
		VEL=80;
		VELSALTO=80;
		DIR=0;
		}
		}
		}


	
//Movimiento DERECHA

		if(IsKeyDown(28))
		{
		if(IsKeyDown(36))
		{
		if(ANC="Run")
		{
		if(self.animate_at_end)
		{
		Animate("Run");
		}
		self.ideal_yaw= ConvertDegrees(180);
		VEL=150;
		VELSALTO=150;
		DIR=0;
		}
		else
		{
		ANC="Run";
		AnimateBlend("Run",0.2);
		VEL=150;
		VELSALTO=150;
		DIR=0;
		}
		}
		else
		{
		if(ANC="Walk")
		{
		if(self.animate_at_end)
		{
		Animate("Walk");
		}
		self.ideal_yaw= ConvertDegrees(180);
		VEL=80;
		VELSALTO=80;
		DIR=0;
		}
		else
		{
		ANC="Walk";
		AnimateBlend("Walk",0.2);
		self.ideal_yaw= ConvertDegrees(180);
		VEL=80;
		VELSALTO=80;
		DIR=0;
		}
		}
		}

//Si no se presionan botones

if(((IsKeyDown(15))=false)and((IsKeyDown(26))=false)and
((IsKeyDown(27))=false)and((IsKeyDown(28))=false))
{
		if(ANC="Idle")
		{
		if(self.animate_at_end)
		{
		Animate("Idle");
		}
		DIR=0;
		VEL=0;
		}
		else
		{
		ANC="Idle";
		AnimateBlend("Idle",0.5);
		}
		DIR=0;
		VEL=0;
		}
		}

}
}]


//Ordenes dea CAIDA

Caida[()
{
walkmove(self.current_yaw+DIR, VELSALTO);
self.yaw_speed=9999;
self.current_yaw=self.ideal_yaw;
ChangeYaw();
PlayerRender(false);

	if(ANC="Fall")
		{
	if(self.animate_at_end)
		{
		Animate("Fall");
		}
		}
	else
		{
		ANC="Fall";
		AnimateBlend("Fall",0.5);
		}

	if(IsKeyDown(15))
		{
		DIR=0;
		}
	else
		{
		if(VELSALTO>0)
		{
		VELSALTO=VELSALTO-0.5;
		}
		}
		if(self.IsFalling=false)
		{
		VEL=0;
		DIR=0;
		self.think="Movimientos";
		}
	else
		{
		if(IsKeyDown(15))
		{
		self.think="Salto2";
		}
		}

}]

Caida2[()
{
walkmove(self.current_yaw+DIR, VELSALTO);
self.yaw_speed=9999;
self.current_yaw=self.ideal_yaw;
ChangeYaw();
PlayerRender(false);

	if(ANC="Fall")
		{
	if(self.animate_at_end)
		{
		Animate("Fall");
		}
		}
	else
		{
		ANC="Fall";
		AnimateBlend("Fall",0.2);
		}

	if(IsKeyDown(15))
		{
		DIR=0;
		}
	else
		{
		if(VELSALTO>0)
		{
		VELSALTO=VELSALTO-0.2;
		}
		}
		if(self.IsFalling=false)
		{
		VEL=0;
		DIR=0;
		self.think="Movimientos";
		}
		

}]




//Ordenes de SALTO

InicioSalto[()
{
self.yaw_speed=9999;
self.current_yaw=self.ideal_yaw;
ChangeYaw();
PlayerRender(false);

	if(ANC="InicioSalto")
		{
		if(self.animate_at_end)
		{
		Animate("JumpStart");
		self.think="Salto";
		}
		}
		else
		{
		ANC="InicioSalto";
		Animate("JumpStart");
		}

}]

Salto[()
		{
		ForceUp(80);
		self.think="Caida";

}]



Salto2[()
		{
		ForceUp(140);
		self.think="Caida2";

}]

}

It's simple. All you have to do is put a pawn,

Start with the command "Start" and the pawn tipe of "Virgil.act."

Thanks and see you soon.

Post Reply