Player pawn

Topics regarding Scripting with Reality Factory
User avatar
Sph!nx
Posts: 297
Joined: Thu Feb 22, 2007 7:26 pm

Re: Player pawn

Post by Sph!nx »

Many thanks!

It works, but not completely. When the game first loads I still start with the old player and after a few seconds I can behond the new pawn. Also, the 'old' player model is not rendered, its still there. I can still see the gun, hear him walk and control his movements.

Is there something to be done it an .ini or something?

Here's my script so far :

Code: Select all

{
	

Spawn[()
   {
		Console(true);
		PlayAnimation("anim_idle", true, "");
		LowLevel("Setup");
   }]
   
   
   Setup[()
   {
      AttachCamera();
      PlayerRender(false);
   }]


} 
Regards Sph!nx

Sven Co-op, DevEd: Development & Editing
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Player pawn

Post by QuestOfDreams »

When the game first loads I still start with the old player and after a few seconds I can behond the new pawn.
Now look at your script again and think what you're doing: You're playing an animation of your pawn and only then you're hiding the default player.
Also, the 'old' player model is not rendered, its still there. I can still see the gun, hear him walk and control his movements. Is there something to be done it an .ini or something?
Now ask yourself: Why do I see the gun?
Because the default player owns one.
How did the default player get the gun?
We gave it to him by specifying it in the player's attribute file.
What can we do about it?
Don't give the default player a gun. Be mean and take it away from him. (hint: initial = 0)

Ask yourself similar questions about the sound. (hint: environment.ini, playersetup.ini)
User avatar
Sph!nx
Posts: 297
Joined: Thu Feb 22, 2007 7:26 pm

Re: Player pawn

Post by Sph!nx »

Excellent! Thanks a lot! Your explanation gave me a whole other view on how to really look at this stuff!

Everything works so far now! My next objective is to be able to look around and walk forward by pressing the 'W' key.

I think I understand a little more now how to approach the script and how to implement it but I'm sure I will bug you guys some more :P
Regards Sph!nx

Sven Co-op, DevEd: Development & Editing
User avatar
Sph!nx
Posts: 297
Joined: Thu Feb 22, 2007 7:26 pm

Re: Player pawn

Post by Sph!nx »

I was a bit premature I think. The example Dinamita gave me is still quite complex for me.

I could spam this thread with more questions but a clear example would work better so I have a little request. Does someone have a very basic script for me (with perhaps some extra info in comments "//")?

If someone could write one for me I don't need much, simply look around (mouse) and walk forward by pressing the "w" key and playing the animation "anim_walk".

This is what I have so far :

Code: Select all

{

Spawn[()
   {
		Console(true);
		LowLevel("Setup");
		PlayAnimation("anim_idle", true, "");
   }]
   
   
   Setup[()
   {
		AttachCamera();
		PlayerRender(false);
		self.think = "controls";
   } ]
   
   controls[ ()
   {
		MouseControlledPlayer(true);
   } ]
}
If I would have such simple script as an example it might be easier for me to understand. From here, I will be implementing more options on my own but I really need this ... can anyone help me? Thanks!
Regards Sph!nx

Sven Co-op, DevEd: Development & Editing
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Re: Player pawn

Post by Danimita92 »

Well I can't provide you with one but I will help you with this script. First of all, take away the mousecontrolledplayer true, and instead put:
self.ideal_yaw=self.player_yaw;

This makes the scripted player's angles the same as the players, and the player's angles are the ones the camera is aiming at. Meaning it'll act like a real player, or at least rotation-wise.
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Re: Player pawn

Post by Jay »

I think the best thing is to let him evolute it a bit more, this way he learns the most.

I would leave the MouseControlledPlayer(true), because this is what ensures that the players angles are determined by the mouse. :wink:

The self.ideal_yaw=self.player_yaw is a design desicion. It could be that he wants to have an all-around view of the player without changing its direction (This would leave the camera attached to the player though and the player would be moved to fit the pawn's position). Or that he wants to make a rotating system which uses the keyboard...
Everyone can see the difficult, but only the wise can see the simple.
-----
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Re: Player pawn

Post by Danimita92 »

But the player is controlled by default with the mouse, right? Anyway, I'd stick with the basic rotation at first, and then if you want to do things like what I did in my project "Survivor Chronicles: The Island": http://youtube.com/watch?v=aAHElfNIkuk
Then you could change it later on, once you're a little more used to scripting.
User avatar
Sph!nx
Posts: 297
Joined: Thu Feb 22, 2007 7:26 pm

Re: Player pawn

Post by Sph!nx »

Thanks a lot so far guys!

Still don't know how to approach the movement and controls so I might base my first game on the game play reality factory standard offers. Like the original player will be remodeled, but will use the same skeleton, animations and code.

Then I will script in my own little features. I guess starting of with a player is a bit to advanced scripting to start with.

Now I just need some great concept ideas...
Regards Sph!nx

Sven Co-op, DevEd: Development & Editing
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Player pawn

Post by Juutis »

Moving the pawn forward when 'W' is pressed:
walkmove(float YawAngle, float Distance );
Move the pawn at a speed of Distance texels per second in the direction specified by YawAngle. If the move was successful the function will return true.
bool IsKeyDown(int Key# );

Returns true or false if the specified key number Key# is being pressed. Use the self.key_pressed script to display the mapping of the keyboard.
Animate(char *Animation );
Set the Pawn actor's current animation to Animation.

When we put this stuff together we get:

Code: Select all

if(IsKeyDown(15))
{
     Animate(<YOUR WALK ANIMATION>);
     walkmove(self.current_yaw,<YOUR WALKING SPEED>);
}
(self.current_yaw is the direction the pawn is facing and putting it in the walkmove command will move the pawn to that direction)
Pain is only psychological.
User avatar
Sph!nx
Posts: 297
Joined: Thu Feb 22, 2007 7:26 pm

Re: Player pawn

Post by Sph!nx »

Excellent! Thanks a lot, m8! Will try to implement this! Also gonna try to do the mouse look from the hints I got from Dinamita and Jay.

Really guys, I'm very grateful for your help so far! :D
Regards Sph!nx

Sven Co-op, DevEd: Development & Editing
User avatar
Graywolf
Posts: 75
Joined: Mon Apr 14, 2008 8:36 pm
Location: Anchorage, Alaska
Contact:

Re: Player pawn

Post by Graywolf »

Just my little comment on this... When doing a scripted player, it's best to stay in low-level, unless you absolutely have to use something in high-level. Also, while it's not heavily commented, there is a very good example(Dan Valeo's work, if I remember correctly) in the scripts/sample folder. It accomplishes your objectives, and more.
"So, what's the life of a programmer like?" "...Huh? What life?!"

RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599
Post Reply