Author Topic: Gun recoil coding, need help  (Read 2974 times)

I know how to code recoil to where it sends a vertical impulse and the gun kicks up, but it only emits false recoil, what I mean is the gun kicks up but the bullets shoot as if the gun didn't kick at all (gun is in the sky, bullets shoot straight forward) I was wondering if there was a way that the bullets would follow the gun on the vertical impulse, as in; how ever high the gun kicks in the air the bullets follow the muzzle, anyways if I could get some answers or some help that would be great, thanks.

So you want to curve a bullet?

So you want to curve a bullet?

The bullet is meant to still go straight, he just wants the aim to change with where the gun is pointing. So like if you sit+crouch the bullet goes up instead of at the cross hair.

http://www.youtube.com/watch?v=pypFL0GFnRU

skip to 0.20 and whatch him shoot the guns, you see how the gun kicks up and the bullets followed where the gun was kicking? thus making that pattern on the wall? this is what I mean, because the current way I know how to make recoil kicks the gun upwards but the bullets just shoot straight on.

 I want to know how to this.

I don't think you can do that.

I don't think you can do that.
I think someone made a gun that does this. I remember it from a trench war.

Unfortunately I think only the client can control the rotation of their character. You could code the spread of the gun to tend upwards, I believe.

Unfortunately I think only the client can control the rotation of their character. You could code the spread of the gun to tend upwards, I believe.

ok that might work, and over the night I was thinking, would this work if the gun had a recoil animation instead of a vertical impulse?

you can actually rotate a player (pitch and yaw) serversided. All you have to do is make an AIConnection take control of them (dont worry, they will still have control) and you can do setMove to change their pitch and yaw.

It seems to be a very obscure function, but has many uses.

you can actually rotate a player (pitch and yaw) serversided. All you have to do is make an AIConnection take control of them (dont worry, they will still have control) and you can do setMove to change their pitch and yaw.

It seems to be a very obscure function, but has many uses.

Could you do something like this?

Code: [Select]
%player = new AIPlayer(rename : %client.player);
rename.setName("");
%client.player.setControlObject(%player);
%client.player = %player;

You dont need to do that, instead, do this

Code: [Select]
%ai = new AIConnection();
%ai.setControlObject(%player);

%ai.setMove("pitch",%speed); //Move them along at %speed
%ai.schedule(200,setMove,"pitch",0); //it will move %speed for 200 ms and stop
//Repeat for yaw

%ai.delete(); //or continue using it
« Last Edit: July 16, 2014, 04:23:04 PM by Wrapperup »

You dont need to do that, instead, do this

Code: [Select]
%ai = new AIConnection();
%ai.setControlObject(%player);

%ai.setMove("pitch",%speed); //Move them along at %speed
%ai.schedule(200,setMove,"pitch",0); //it will move %speed for 200 ms and stop
//Repeat for yaw

%ai.delete(); //or continue using it

Wouldn't the player get a weird flashing effect as though his camera is teleporting back and forth?

Wouldn't the player get a weird flashing effect as though his camera is teleporting back and forth?
Yes.