Page 1 of 1
Scripted Weapon doubt
Posted: Tue Apr 08, 2008 6:44 pm
by Danimita92
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?
Re: Scripted Weapon doubt
Posted: Tue Apr 08, 2008 7:36 pm
by darksmaster923
Re: Scripted Weapon doubt
Posted: Tue Apr 08, 2008 11:02 pm
by Danimita92
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:
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 the weapon script:
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);
}
}]
}
Thanks for your time, i hope you know how to help.
Re: Scripted Weapon doubt
Posted: Wed Apr 09, 2008 1:12 am
by darksmaster923
first in your camera 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();
}
}]
}
you have attachcamera(); on if states. you should have it start the beginning.
and you have to add this to the weapon script
camerapitchtemp = self.camera_pitch*10;
PositionToPawn("player",offsetX,75+offsetY+camerapitchtemp,offsetZ+camerapitchtemp,true,false);
juutis's one is probably better, but the code goes off the screen for me
Re: Scripted Weapon doubt
Posted: Wed Apr 09, 2008 8:10 pm
by Danimita92
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:
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;
}
}]
The camera script:
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);
}
}]
}
And the weapon:
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);
}
}]
}
Thanks for your help

Re: Scripted Weapon doubt
Posted: Sat Apr 12, 2008 11:37 pm
by Danimita92

Nobody? I really want to fix this, or else my project can't go on.
Re: Scripted Weapon doubt
Posted: Sun Apr 13, 2008 2:59 am
by darksmaster923
sorry, didnt see your post before. so the weapon rotates, but doesnt move?
Re: Scripted Weapon doubt
Posted: Sun Apr 13, 2008 1:00 pm
by Danimita92
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.
Re: Scripted Weapon doubt
Posted: Sun Apr 13, 2008 1:26 pm
by Juutis
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.