Page 1 of 1
Scripted player's weapon shoots wrong.
Posted: Thu Jul 03, 2008 6:05 pm
by Danimita92
Hi everybody, let me first say that this is one of my first tries to make my scripted player shoot. Okay, so in the scripted player's script I've got this for when he shoots:
Code: Select all
if(IsKeyDown(72))
{
SetTargetPoint(0, 0, 216);
FireProjectile("disk","Hand_R",0,0,0,"Health"); // shoot the projectile
AnimationSpeed(3);
Animate("Shoot");
}
And it does shoot, but what happens is that
1- It shoot's a little to the left of where I'd like it to shoot.
2- When I aim up and shoot, the projectiles go towards the floor, and when I aim to the floor, the projectiles go towards the ceiling.
How could I fix these problems? Thanks in advance.
Re: Scripted player's weapon shoots wrong.
Posted: Sat Jul 05, 2008 1:28 pm
by Danimita92
Nobody? Is it hard to understand my problem, or is it just you don't know the answer
Re: Scripted player's weapon shoots wrong.
Posted: Sat Jul 05, 2008 3:15 pm
by Jay
You set a specific point in space as your target point. That means the projectile always wants to fly there. Try to use FireProjectileBlind instead or modify the target point to where you want it.
Re: Scripted player's weapon shoots wrong.
Posted: Mon Jul 07, 2008 2:40 pm
by Danimita92
Arg... it won't work! I change FireProjectile for FireProjectileBlind and included the other two settings you can put in this version (I'm using 0.75C) and when I hit the shoot button it'll crash with the typical "Send Report" button and all that. This is what I have:
Code: Select all
if(IsKeyDown(72))
{
FireProjectileBlind("disk","Hand_R",12,0,100,"Health","Camera",100);
AnimationSpeed(3);
Animate("Shoot");
Re: Scripted player's weapon shoots wrong.
Posted: Tue Jul 08, 2008 4:49 pm
by Danimita92
It won't work, I reinstalled RF and now it won't crash when I use FireProjectileBlind, but it still goes up when I aim down, and viceversa:
Code: Select all
if(IsKeyDown(72))
{
FireProjectileBlind("disk","Hand_R",12,0,100,"Health",self.camera_pitch,100);
AnimationSpeed(3);
Animate("Shoot");
}
Re: Scripted player's weapon shoots wrong.
Posted: Tue Jul 08, 2008 4:56 pm
by bernie
Just a thought... make the camera pitch a negative value ie.
FireProjectileBlind("disk","Hand_R",12,0,100,"Health",-self.camera_pitch,100);
and see what happens.
Re: Scripted player's weapon shoots wrong.
Posted: Tue Jul 08, 2008 5:16 pm
by Danimita92

Nothing, it won't work. I even tried multiplying self.camera_pitch by (-1) but it won't do anything. Anyway I uploaded a youtube video that shows what's happening.
http://www.youtube.com/watch?v=XaqIh9xN6dk
Re: Scripted player's weapon shoots wrong.
Posted: Tue Jul 08, 2008 7:21 pm
by Juutis
Would you mind posting the whole script? Or at least all the parts that have something to do with shooting (Rotating the player etc.). I had a similar problem but playing around with different rotations fixed it.
Re: Scripted player's weapon shoots wrong.
Posted: Tue Jul 08, 2008 8:34 pm
by Danimita92
Sure, here it is:
Code: Select all
{
Spawn[()
{
BlendToAnimation("Aimdown", 1, false, "");
self.pitch_speed = 280;
Console(false); //Turns on debug
HideFromRadar(true);
BoxWidth(20);
BoxHeight(40);
LowLevel("Setup");
}]
Setup[()
{
yaw_speed = 180;
self.ideal_pitch = -self.camera_pitch;
self.ideal_yaw = self.player_yaw;
SetTargetPoint(0, 0, 0);
if(IsKeyDown(73))
{
PawnRender(true);
AnimationSpeed(1);
yaw_speed = 1280;
self.ideal_pitch = -self.camera_pitch;
self.ideal_yaw = self.player_yaw;
ChangeYaw();
ChangePitch();
camerapitchtemp = self.camera_pitch*10;
PositionToPawn("rotation",0,75+0+camerapitchtemp,0+camerapitchtemp,true,false);
if(self.animate_at_end = true)
{
Animate("Aimdown");
}
if(IsKeyDown(72))
{
FireProjectileBlind("disk","Hand_R",12,0,100,"Health","Camera",100);
AnimationSpeed(3);
Animate("Shoot");
}
}
else
{
PawnRender(false);
SetEventState("AIM", false);
}
}]
}
When you right click, the pawn appears, and rotates like a normal first person weapon. Then when you left-click it shoots.
Re: Scripted player's weapon shoots wrong.
Posted: Tue Jul 08, 2008 8:56 pm
by Juutis
Oh, you've faked it really well!

It really looks like the guy is only turning his upper body up/down but actually the whole model is turning. Well, yeah, you can't see his legs unless you aim very low. Anyway, well done.
When my scripted weapons were shooting up when aiming down and vice versa I did a few things:
Initial (when things went wrong):
Pawn.ini -> actorrotation = 0 180 0
script -> self.ideal_pitch = self.camera_pitch; and self.ideal_yaw = self.player_yaw;
3D model -> just like you'd expect it to be, facing forward
Fixed:
Pawn.ini -> actorrotation = 0 0 0
script -> self.ideal_pitch = self.camera_pitch; and self.ideal_yaw = self.player_yaw; (no changes)
3D model -> Now here's the trick; Rotate the model 180 degrees in the modeling application to make up for the change in pawn.ini. So now your model is facing the back but the actorrotation in Pawn.ini makes it correct again. Now, if you start thinking about it, how the changes affect the way the pawn rotates and stuff, it makes sense. I'm not gonna even try to explain why but it really does.

And for me it fixed the problem.

Re: Scripted player's weapon shoots wrong.
Posted: Wed Jul 09, 2008 12:23 pm
by Danimita92
Loads of thanks, Juutis, it worked perfectly

I owe you one