Scripted Weapon doubt
-
- Posts: 335
- Joined: Sat Feb 09, 2008 5:47 pm
- Location: Lanzarote/Canary Islands/Spain
Scripted Weapon doubt
Hi everybody. I've got a little doubt, you see I'm creating a Scripted Weapon in first person view, but I can't manage to make it rotate upwards or downwards like a normal weapon. Is there a way to do this?
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
Re: Scripted Weapon doubt
Herp derp.
-
- Posts: 335
- Joined: Sat Feb 09, 2008 5:47 pm
- Location: Lanzarote/Canary Islands/Spain
Re: Scripted Weapon doubt
Thanks, I tried, but it wont work.
I¡ll explain:
-I'm using a scripted player, with a camera in first person attached to an entity with offsets, so even if it's in a first person view, you see the scripted player from behind.
- When I'm pressing a certain key, the camera's offset take the camera closer to the player, and the scripted player stops being shown.
- Then, the scripted weapon appears where the scripted player was, and...
Now this weapon should move like a real weapon. I need to know how to do this. I looked at the other post, and have been all afternoon trying but several wrong things have happened, like the pawn rotating the wrong way (i look up, it rotates backwards and viceversa).
Here's the camera's script:
And the weapon script:
Thanks for your time, i hope you know how to help.
I¡ll explain:
-I'm using a scripted player, with a camera in first person attached to an entity with offsets, so even if it's in a first person view, you see the scripted player from behind.
- When I'm pressing a certain key, the camera's offset take the camera closer to the player, and the scripted player stops being shown.
- Then, the scripted weapon appears where the scripted player was, and...
Now this weapon should move like a real weapon. I need to know how to do this. I looked at the other post, and have been all afternoon trying but several wrong things have happened, like the pawn rotating the wrong way (i look up, it rotates backwards and viceversa).
Here's the camera's script:
Code: Select all
{
Spawn[()
{
Console(true);
LowLevel("Init");
}]
Init[()
{
if(GetEventState("AIM")=false)
{
PositionToPawn("jugador",-65,-5,-145,true,true);
AttachCamera();
}
if(IsKeyDown(73))
{
PositionToPawn("weapon",-45,15,-55,true,true);
AttachCamera();
}
}]
}
Code: Select all
{
Spawn[()
{
self.pitch_speed = 182;
Console(true); //Turns on debug
HideFromRadar(true);
BoxWidth(20);
BoxHeight(40);
LowLevel("Setup");
}]
Setup[()
{
if(IsKeyDown(73))
{
PawnRender(true);
PositionToPawn("jugador",0,0,0,true,true);
self.ideal_pitch = self.camera_pitch;
self.ideal_yaw = self.player_yaw;
ChangeYaw();
ChangePitch();
}
else
{
SetEventState("AIM", false);
}
}]
}
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
Re: Scripted Weapon doubt
first in your camera script
you have attachcamera(); on if states. you should have it start the beginning.
and you have to add this to the weapon script
Code: Select all
{
Spawn[()
{
Console(true);
LowLevel("Init");
}]
Init[()
{
if(GetEventState("AIM")=false)
{
PositionToPawn("jugador",-65,-5,-145,true,true);
AttachCamera();
}
if(IsKeyDown(73))
{
PositionToPawn("weapon",-45,15,-55,true,true);
AttachCamera();
}
}]
}
and you have to add this to the weapon script
juutis's one is probably better, but the code goes off the screen for mecamerapitchtemp = self.camera_pitch*10;
PositionToPawn("player",offsetX,75+offsetY+camerapitchtemp,offsetZ+camerapitchtemp,true,false);
Herp derp.
-
- Posts: 335
- Joined: Sat Feb 09, 2008 5:47 pm
- Location: Lanzarote/Canary Islands/Spain
Re: Scripted Weapon doubt
First of all, thanks for your time. I'm getting there. Now my problems are that each time the weapon appears, it appears looking at the same direction the pawn started. When i rotate the camera horizontally, it'll rotate around it, but the weapon wont rotate. AND,
when i rotate the camera vertically, it rotates, but the other way around (if i look up, it'll rotate to look downwards and viceversa).
The player is doing this at the moment:
The camera script:
And the weapon:
Thanks for your help 

The player is doing this at the moment:
Code: Select all
Aim[()
{
if(IsKeyDown(73))
{
PlayerRender(false);
self.ideal_yaw=self.player_yaw;
ChangeYaw();
PawnRender(false);
self.ThinkTime=0;
}
else
{
self.think = "RunPlayer";
return 0;
}
}]
Code: Select all
{
Spawn[()
{
Console(true);
LowLevel("Init");
}]
Init[()
{
AttachCamera();
if(GetEventState("AIM")=false)
{
PositionToPawn("jugador",-65,-5,-145,true,true);
}
if(IsKeyDown(73))
{
PositionToPawn("jugador",-45,15,-55,true,true);
}
}]
}
Code: Select all
{
Spawn[()
{
self.pitch_speed = 182;
Console(true); //Turns on debug
HideFromRadar(true);
BoxWidth(20);
BoxHeight(40);
LowLevel("Setup");
}]
Setup[()
{
if(IsKeyDown(73))
{
PawnRender(true);
self.ideal_pitch = self.camera_pitch;
self.ideal_yaw = self.player_yaw;
ChangeYaw();
ChangePitch();
camerapitchtemp = self.camera_pitch*10;
PositionToPawn("jugador",0,75+0+camerapitchtemp,0+camerapitchtemp,true,false);
}
else
{
PawnRender(false);
SetEventState("AIM", false);
}
}]
}

-
- Posts: 335
- Joined: Sat Feb 09, 2008 5:47 pm
- Location: Lanzarote/Canary Islands/Spain
Re: Scripted Weapon doubt

- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
Re: Scripted Weapon doubt
sorry, didnt see your post before. so the weapon rotates, but doesnt move?
Herp derp.
-
- Posts: 335
- Joined: Sat Feb 09, 2008 5:47 pm
- Location: Lanzarote/Canary Islands/Spain
Re: Scripted Weapon doubt
The camera rotates around it horizontaly, the actual weapon only rotates verticaly. And when it rotates verticaly, it does so the other way around. I look up, ir rotates to look down, and viceversa.
PS: I dont want the weapon to move, just rotate like a normal weapon.
PS: I dont want the weapon to move, just rotate like a normal weapon.
Re: Scripted Weapon doubt
You're missing 'self.yaw_speed = ... ;' in the weapon script. Dunno if this is the problem though. Normally I would test the script in RF myself but at the moment I don't have the time for that.
***EDIT***
Oh, and try 'self.ideal_pitch = -self.camera_pitch;' for the pitch issue.
***EDIT***
Oh, and try 'self.ideal_pitch = -self.camera_pitch;' for the pitch issue.
Pain is only psychological.