Depending on the actorrotation parameter set for the pawn and for the default player, either the pawn moves opposite the default player and moves correctly (while the default player moves in a mirror image way), or moves in the same direction as the default player but both move back when I hit forward and forward when I hit back. I'm using the genericplayer.s script for the movement so I'm not sure what's up
Lovely Pawns!
Lovely Pawns!
So I just figured out (meaning read in tutorials) that I can use pawns in order to make my own control system through scripting. I've set up a pawn to move about, however, I'm having an issue.
Depending on the actorrotation parameter set for the pawn and for the default player, either the pawn moves opposite the default player and moves correctly (while the default player moves in a mirror image way), or moves in the same direction as the default player but both move back when I hit forward and forward when I hit back. I'm using the genericplayer.s script for the movement so I'm not sure what's up
Depending on the actorrotation parameter set for the pawn and for the default player, either the pawn moves opposite the default player and moves correctly (while the default player moves in a mirror image way), or moves in the same direction as the default player but both move back when I hit forward and forward when I hit back. I'm using the genericplayer.s script for the movement so I'm not sure what's up
I think there is something wrong with the genericplayer.s movement. I haven't noticed it before until yesterday, because I normally add this line to the genericplayer.s in RunPlayer():
PlayerToPosition(0, 0, 0, false);
This places the the player to the position of the pawn. Since this is done every frame, the player's position will always be the same as the pawn's.
PlayerToPosition(0, 0, 0, false);
This places the the player to the position of the pawn. Since this is done every frame, the player's position will always be the same as the pawn's.
Everyone can see the difficult, but only the wise can see the simple.
-----
-----
Well I used a different approach to fix the problem above, but thanks
On to more issues!
Edit: Yeap, that's the workaround I used too
Edit #2: Ah you can just add it once instead of adding it everywhere like I did? You sir are much more clever than I! Thanks!
Another interesting problem, the following code...:
I don't know how, but it seems somewhere along my coding my pawn picked up some abilities of the player, even though the player is not rendered. For example, it can jump when I press space bar, without me having coded that action. Also, the running works as a toggle, like the player does, however, in this script it is coded to work by holding it down. Strange. I know it's probably some typo or something but any help would be appreciated 
Edit: So apparently the reason it's doing this is because somewhere I'm breaking the script and making it not load at all, hence I'm actually controlling the player and not the pawn. Hmmm...
Edit: Yeap, that's the workaround I used too
Edit #2: Ah you can just add it once instead of adding it everywhere like I did? You sir are much more clever than I! Thanks!
Another interesting problem, the following code...:
Code: Select all
{
FIREAMMO [pistolbullet] // Projectile fired by pawn
FIREEFFECT [Electric] // muzzleflash effect
WEAPONMODEL [Laser] // Weapon held by pawn
FIRERATE [0.1] // Weapon firing rate
GROUP [Friendly] // Pawn Group - must be targetted by enemies
PLAYERSPEED [200] // Walk Speed
HEALTHATTRIB [health] // health attribute given to pawn
HEALTHAMOUNT [500] // amount of health given to pawn
DAMAGEATTRIB [health] // Atribute damaged by pawn
BOX [24] // Box width
IDLEANIM [Idle] // Idle AnimationSpeed
SHOOTANIM [Shoot3] // Shoot anim
WALKANIM [Walk] // Walk anim
BACKANIM [Walk] // walk back anim
RUNANIM [Run] //Run anim
STRAFELEFT [recon_strafe_left] // Strafe left anim
STRAFERIGHT [recon_strafe_right] // Strafe right anim
INTERANIM [Hit] // Pawn interact anim
DEATHANIM [Die] // Death Anim
ROOTBONE [Bip01] // Pawn root bone
WEAPONHAND [Bip01 L Hand] // Pawn weapon bone
K_INTER [73] // INTERACT KEY - RIGHT MOUSE
K_FIRE [72] // FIRE KEY - LEFT MOUSE
K_FOR [15] // FORWARD - W
K_BAK [27] // BACK - S
K_LEFT [26] // STRAFE LEFT - A
K_RIGHT [28] // STRAFE RIGHT - D
K_RUN [36] // RUN - LEFT SHIFT KEY
K_JUMP [46] // JUMP - SPACE
ANIM [string] // Do Not Edit
ANC [0] // Do Not Edit, Currently Set So: 0 = Idle, 1 = Run, 2 = WalkForward, 3 = WalkBackward, 4 = Strafe Left, 5 = Strafe Right, 6 = Shoot
LASTANC [0] // Do Not Edit
DIR [0] // Do Not Edit
AT [0.5] // Do Not Edit
INTER [string] // Do Not Edit
TM [0] // Do Not Edit
SPEED [0] //Do Not Edit
Spawn[()
{
Console(false);
BoxWidth(BOX);
SetGroup(GROUP);
AttributeOrder(HEALTHATTRIB,HEALTHAMOUNT,"Die");
//SetWeapon(WEAPONMODEL);
LowLevel("Setup");
}]
Setup[()
{
AttachCamera();
self.yaw_speed=1000;
AnimateHold(IDLEANIM);
ANIM=StringCopy(IDLEANIM);
ANC=0;
LASTANC=0;
TM=self.time;
self.think="RunPlayer";
}]
RunPlayer[()
{
AttachCamera();
//debug(self.key_pressed);
//self.ideal_yaw=-self.player_yaw;
//ChangeYaw();
MatchPlayerAngles();
PlayerRender(false);
DIR=0; // Default straight
SPEED=0; //Default - no motion
AT=0.1; //Default
ANC=0; //Default
AnimationSpeed(1); //Default
//handle health status
if(self.health < 1)
{
HighLevel("Die");
return 0;
}
//handle controls
if(IsKeyDown(K_INTER))
{
//strike/interact
AnimateBlend(INTERANIM,0.25);
self.think="Interact";
return 0;
}
if(IsKeyDown(K_FOR))
{
if(IsKeyDown(K_RUN))
{
//left shift key - toggle run
PlayerToPosition(0,0,0,true,false);
ANIM=StringCopy(RUNANIM);
ANC=1;
SPEED=Integer(PLAYERSPEED)*2;
}
else
{
//walk
PlayerToPosition(0,0,0,true,false);
ANIM=StringCopy(WALKANIM);
ANC=2;
SPEED=Integer(PLAYERSPEED);
}
}
if(IsKeyDown(K_BAK))
{
//back
PlayerToPosition(0,0,0,true,false);
ANIM=StringCopy(BACKANIM);
ANC=3;
DIR=ConvertDegrees(180);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_LEFT))
{
//strafe left
PlayerToPosition(0,0,0,true,false);
ANIM=StringCopy(STRAFELEFT);
//make strafe transition smoother
AT=0.5;
ANC=4;
DIR=ConvertDegrees(90);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_RIGHT))
{
//strafe right
PlayerToPosition(0,0,0,true,false);
ANIM=StringCopy(STRAFERIGHT);
//make strafe transition smoother
AT=0.5;
ANC=5;
DIR=ConvertDegrees(270);
SPEED=Integer(PLAYERSPEED);
}
if(ANC < 1)
{
//no button
ANIM=StringCopy(IDLEANIM);
AT=0.5;
}
//handle animations
if(Integer(LASTANC) != Integer(ANC))
{
AnimateBlend(ANIM,AT);
}
LASTANC=Integer(ANC);
if(self.animate_at_end)
{
AnimateHold(ANIM);
}
//handle motions
walkmove(self.current_yaw+DIR,SPEED);
}]
Interact[()
{
if(self.animate_at_end)
{
INTER=TraceToActor(ROOTBONE,0,0,32);
if(INTER != "FALSE")
{
SetEventState(INTER # "Trigger",true);
}
self.think="RunPlayer";
return 0;
}
}]
Die[()
{
AnimateStop(DEATHANIM,0,"");
}]
}
Edit: So apparently the reason it's doing this is because somewhere I'm breaking the script and making it not load at all, hence I'm actually controlling the player and not the pawn. Hmmm...
Yes that could be true that you're at some point breaking the script. You can be sure if you change the line Console(false); to Console(true);
When you get a bluish text appear on the left-up corner of the screen, then you know the script has been loaded. If there is no such text in the game, then something is wrong with the script in a way that it is not loaded. (That is called a ReaderScript error) When there is a text, it might give you some clues to the origin of the error. If you're unsure what it means, then you may post the text that is shown.
When you get a bluish text appear on the left-up corner of the screen, then you know the script has been loaded. If there is no such text in the game, then something is wrong with the script in a way that it is not loaded. (That is called a ReaderScript error) When there is a text, it might give you some clues to the origin of the error. If you're unsure what it means, then you may post the text that is shown.
Everyone can see the difficult, but only the wise can see the simple.
-----
-----
In your text it looks like it's split into two lines. If it is in your script also, then either make it one line or comment out the second line.ANC [0] // Do Not Edit, Currently Set So: 0 = Idle, 1 = Run, 2 = WalkForward, 3 = WalkBackward, 4 = Strafe Left, 5 = Strafe Right, 6 = Shoot
Was it that?
Everyone can see the difficult, but only the wise can see the simple.
-----
-----
- vrageprogrammer
- Posts: 566
- Joined: Wed Oct 31, 2007 2:59 pm
- Location: On top of a tree
- Contact:
- vrageprogrammer
- Posts: 566
- Joined: Wed Oct 31, 2007 2:59 pm
- Location: On top of a tree
- Contact:
Couple of more problems. I'm trying to make a levitating scripted player, but when I use the Gravity(false) command, even though my pawn doesn't fall, the default player does (but very slowly) taking my camera with him! I need to have the camera attached to the default player to get the type of controls I want. I can't seem to figure out why. Also, another problem, when facing the camera and jumping towards it (especially when a wall is close behind the camera) it crashes RF. The code is below, I'll keep working on these problems and others mentioend above, but any help is appreciated 
Code: Select all
{
FIREAMMO [pistolbullet] // Projectile fired by pawn
FIREEFFECT [Electric] // muzzleflash effect
WEAPONMODEL [Laser] // Weapon held by pawn
FIRERATE [0.1] // Weapon firing rate
GROUP [Friendly] // Pawn Group - must be targetted by enemies
PLAYERSPEED [200] // Walk Speed
HEALTHATTRIB [health] // health attribute given to pawn
HEALTHAMOUNT [500] // amount of health given to pawn
DAMAGEATTRIB [health] // Atribute damaged by pawn
BOX [24] // Box width
IDLEANIM [Idle] // Idle AnimationSpeed
SHOOTANIM [Shoot3] // Shoot anim
WALKANIM [Walk] // Walk anim
BACKANIM [Walk] // walk back anim
RUNANIM [Run] //Run anim
JUMPANIM [Jump] //Jump anim
STRAFELEFT [recon_strafe_left] // Strafe left anim
STRAFERIGHT [recon_strafe_right] // Strafe right anim
INTERANIM [Hit] // Pawn interact anim
DEATHANIM [Die] // Death Anim
ROOTBONE [Bip01] // Pawn root bone
WEAPONHAND [Bip01 L Hand] // Pawn weapon bone
K_INTER [73] // INTERACT KEY - RIGHT MOUSE
K_FIRE [72] // FIRE KEY - LEFT MOUSE
K_FOR [15] // FORWARD - W
K_BAK [27] // BACK - S
K_LEFT [26] // STRAFE LEFT - A
K_RIGHT [28] // STRAFE RIGHT - D
K_RUN [36] // RUN - LEFT SHIFT KEY
K_JUMP [46] // JUMP - SPACE
K_LEV [34] //LEVITATE KEY - L
ANIM [string] // Do Not Edit
ANC [0] // Do Not Edit
// ANC Currently Set So 0 is Idle
// 1 is Run 2 is WalkForward
// 3 is WalkBackward 4 is Strafe Left
// 5 is Strafe Right 6 is Shoot
// 7 is Falling 8 is Levitating
LASTANC [0] // Do Not Edit
DIR [0] // Do Not Edit
AT [0.5] // Do Not Edit
INTER [string] // Do Not Edit
TM [0] // Do Not Edit
SPEED [0] //Do Not Edit
WALKRUNANIM [string] //Do Not Edit
WALKRUNSPEED [0] //Do Not Edit
WALKRUNANC [0] //Do Not Edit
JUMPMODE [0] //Do Not Edit
SPACEPRESS [0] //Do Not Edit
STORE_Z [0] //Do Not Edit
gravityOn [1] //Do Not Edit - Keeps track if gravity is on or off
Spawn[()
{
Console(false);
BoxWidth(BOX);
SetGroup(GROUP);
AttributeOrder(HEALTHATTRIB,HEALTHAMOUNT,"Die");
//SetWeapon(WEAPONMODEL);
LowLevel("Setup");
}]
Setup[()
{
self.yaw_speed=1000;
AnimateHold(IDLEANIM);
ANIM=StringCopy(IDLEANIM);
AnimationSpeed(2);
ANC=0;
LASTANC=0;
SPACEPRESS=0; //Used to separate button presses for jumps
JUMPMODE = 0; //Default - Not currently jumping
gravityOn = 1; //Default - Gravity is on to start
TM=self.time;
self.think="RunPlayer";
}]
RunPlayer[()
{
//debug(self.key_pressed);
PlayerToPosition(0,0,0,false,false);
//PlayerRender(false);
DIR=0; // Default straight
SPEED=0; //Default - no motion
AT=0.1; //Default
ANC=0; //Default
WALKRUNSPEED = Integer(PLAYERSPEED); //Default for Walking
WALKRUNANIM = StringCopy(WALKANIM); //Default for Walking
WALKRUNANC = 2; //Default for Walking
//handle health status
if(self.health < 1)
{
HighLevel("Die");
return 0;
}
//handle controls
if(IsKeyDown(K_INTER))
{
//strike/interact
AnimateBlend(INTERANIM,0.25);
self.think="Interact";
return 0;
}
if(IsKeyDown(K_LEV))
{
Gravity(false);
gravityOn=0;
flymove(ConvertDegrees(90),0,(75*sin(5*self.time)));
//ANC = 8;
}
else
{
Gravity(true);
gravityOn=1;
}
//Walk & Run Code
if(IsKeyDown(K_RUN))
{
WALKRUNSPEED = Integer(PLAYERSPEED)*2;
WALKRUNANIM = StringCopy(RUNANIM);
WALKRUNANC = 1;
}
if((IsKeyDown(K_FOR)=true) and (IsKeyDown(K_LEFT)=false) and (IsKeyDown(K_RIGHT)=false) and (IsKeyDown(K_BAK)=false))
{
DIR = self.player_yaw + ConvertDegrees(180);
self.ideal_yaw = DIR;
ChangeYaw();
ANIM=StringCopy(WALKRUNANIM);
ANC=Integer(WALKRUNANC);
SPEED=Integer(WALKRUNSPEED);
}
if((IsKeyDown(K_FOR)=false) and (IsKeyDown(K_LEFT)=false) and (IsKeyDown(K_RIGHT)=false) and (IsKeyDown(K_BAK)=true))
{
DIR = self.player_yaw;
self.ideal_yaw = DIR;
ChangeYaw();
ANIM=StringCopy(WALKRUNANIM);
ANC=Integer(WALKRUNANC);
SPEED=Integer(WALKRUNSPEED);
}
if((IsKeyDown(K_FOR)=false) and (IsKeyDown(K_LEFT)=true) and (IsKeyDown(K_RIGHT)=false) and (IsKeyDown(K_BAK)=false))
{
DIR = self.player_yaw + ConvertDegrees(-90);
self.ideal_yaw = DIR;
ChangeYaw();
ANIM=StringCopy(WALKRUNANIM);
ANC=Integer(WALKRUNANC);
SPEED=Integer(WALKRUNSPEED);
}
if((IsKeyDown(K_FOR)=false) and (IsKeyDown(K_LEFT)=false) and (IsKeyDown(K_RIGHT)=true) and (IsKeyDown(K_BAK)=false))
{
DIR = self.player_yaw + ConvertDegrees(90);
self.ideal_yaw = DIR;
ChangeYaw();
ANIM=StringCopy(WALKRUNANIM);
ANC=Integer(WALKRUNANC);
SPEED=Integer(WALKRUNSPEED);
}
if((IsKeyDown(K_FOR)=true) and (IsKeyDown(K_LEFT)=false) and (IsKeyDown(K_RIGHT)=true) and (IsKeyDown(K_BAK)=false))
{
DIR = self.player_yaw + ConvertDegrees(135);
self.ideal_yaw = DIR;
ChangeYaw();
ANIM=StringCopy(WALKRUNANIM);
ANC=Integer(WALKRUNANC);
SPEED=Integer(WALKRUNSPEED);
}
if((IsKeyDown(K_FOR)=true) and (IsKeyDown(K_LEFT)=true) and (IsKeyDown(K_RIGHT)=false) and (IsKeyDown(K_BAK)=false))
{
DIR = self.player_yaw + ConvertDegrees(-135);
self.ideal_yaw = DIR;
ChangeYaw();
ANIM=StringCopy(WALKRUNANIM);
ANC=Integer(WALKRUNANC);
SPEED=Integer(WALKRUNSPEED);
}
if((IsKeyDown(K_FOR)=false) and (IsKeyDown(K_LEFT)=false) and (IsKeyDown(K_RIGHT)=true) and (IsKeyDown(K_BAK)=true))
{
DIR = self.player_yaw + ConvertDegrees(45);
self.ideal_yaw = DIR;
ChangeYaw();
ANIM=StringCopy(WALKRUNANIM);
ANC=Integer(WALKRUNANC);
SPEED=Integer(WALKRUNSPEED);
}
if((IsKeyDown(K_FOR)=false) and (IsKeyDown(K_LEFT)=true) and (IsKeyDown(K_RIGHT)=false) and (IsKeyDown(K_BAK)=true))
{
DIR = self.player_yaw + ConvertDegrees(-45);
self.ideal_yaw = DIR;
ChangeYaw();
ANIM=StringCopy(WALKRUNANIM);
ANC=Integer(WALKRUNANC);
SPEED=Integer(WALKRUNSPEED);
}
//handle jump - Double Jump!
//Are we falling? If not we should be on the ground so we should we are not jumping!
if((self.IsFalling=true) and (gravityOn=1))
{
ANC=7; //Set Jump/Fall animation
}
else
{
JUMPMODE=0;
}
if((IsKeyDown(K_JUMP)=false) and (SPACEPRESS=1)){SPACEPRESS=0;} //Makes sure you have to release and re-press the jump button to jump again.
if((IsKeyDown(K_JUMP)=true) and (SPACEPRESS=0) and (JUMPMODE < 2) and (gravityOn=1)) //Have we performed less than 2 jumps? If so run the jump function.
{
SPACEPRESS=1;
HighLevel("JumpFunc");
ANC=7; //Set Jump/Fall animation
return 0;
}
if(ANC=7)
{
//While jumping, play this anim, even if doing other actions like moving forward.
ANIM=StringCopy(JUMPANIM);
}
if(ANC < 1)
{
//no button
ANIM=StringCopy(IDLEANIM);
AT=0.5;
}
//handle animations
if(Integer(LASTANC) != Integer(ANC))
{
AnimateBlend(ANIM,AT);
}
LASTANC=Integer(ANC);
if(self.animate_at_end)
{
AnimateHold(ANIM);
}
//handle motions
walkmove(DIR,SPEED);
}]
Interact[()
{
if(self.animate_at_end)
{
INTER=TraceToActor(ROOTBONE,0,0,32);
if(INTER != "FALSE")
{
SetEventState(INTER # "Trigger",true);
}
self.think="RunPlayer";
return 0;
}
}]
Die[()
{
AnimateStop(DEATHANIM,0,"");
}]
JumpFunc[()
{
if((self.IsFalling)) //If we're falling do the code below to perform the second jump and set JUMPMODE to 2 to indicate we've performed 2 jumps
{
JUMPMODE = 2;
Jump(JUMPANIM,200,true,"");
}
else //If we haven't performed one jump yet do the code below to perform the first jump and set JUMPMODE to 1 to indicate we've performed 1 jump
{
JUMPMODE=1;
Jump(JUMPANIM,150,true,"");
}
LowLevel("RunPlayer");
return 0;
}]
}