accurate shot

Posted By: demiGod

accurate shot - 08/16/07 21:43

Hi,

i am trying to make a gun shot some balls and it works ok when the player and gun are stopped:

Code:

function create_balls()
{
proc_kill(4);
vec_for_vertex (temp.x, weapon1, 1465);
ent_create (ball_mdl, temp.x, move_balls);
}
}

function move_balls()
{
var ball_speed;
my.pan = camera.pan;
my.tilt = camera.tilt;
ball_speed.x = 50 * time_step;
ball_speed.y = 0;
ball_speed.z = 10 * time_step;
while (my != null)
{
c_move (my, ball_speed, nullvector, ignore_passable);
ball_speed.z -= 3 * time_step;
wait (1);
}
}





The problem is: when the player and gun are moving, when camera.tilt its higher than zero the ball goes up and does not assume the correct tilt.
Also it happens when camera.tilt is less than zero, goes too much down the ball.

Whatīs the problem here?
Thanks.
Posted By: Shadow969

Re: accurate shot - 08/16/07 22:07

maybe try decreasing ball's tilt, instead of changing z-speed. not sure
Posted By: demiGod

Re: accurate shot - 08/16/07 22:09

But i need gravity for the ball to make a curve, dont think changing ballīs tilt will solve the problem...
Posted By: Shadow969

Re: accurate shot - 08/17/07 10:18

if you'll change the ball's tilt, his trajectory will change...
c_move (my, ball_speed, nullvector, ignore_passable);//you use relative movement, so changing entity's orientation will change his trajectory
Posted By: demiGod

Re: accurate shot - 08/17/07 10:36

Yes, its true that changing ballīs tilt will change the trajectory

actually that is the problem, because ballīs tilt is allways camera tilt and works fine with player and gun stopped, i mean, the ball is created right and the movement and gravity is good, no matters what pan ot tilt camera / gun.

The problem is when the player and gun are moving, if i look up the ball is trown too much high, and when look down she goes too much down.

Tried using playerīs speed on ballīs movement but didnt work

More ideas?
Posted By: testDummy

Re: accurate shot - 08/17/07 12:42

Hypothetical and untested...
(edited)
Code:

define _tm1, skill29;
// world speed
define _wSpeed, skill30;
define _wSpeedX, skill30;
define _wSpeedY, skill31;
define _wSpeedZ, skill32;
// relative speed
define _rSpeed, skill33;
define _rSpeedX, skill33;
define _rSpeedY, skill34;
define _rSpeedZ, skill35;
define _prSpeedX, skill36; // parent speed (relative)
define _pwSpeedZ, skill37; // parent speed (world)

function create_balls() {
proc_kill(4);
vec_for_vertex (temp, weapon1, 1465);
ent_create (ball_mdl, temp, move_balls);
}

function move_balls() {
my.pan = camera.pan;
my.tilt = camera.tilt;
if (player != NULL) {
my._prSpeedX = player._rSpeedX;
my._pwSpeedZ = player._wSpeedZ;
}
while (me != null) {
my._tm1 += 0.0625 * time_step;
my._rSpeedX = max(0, (5 + my._prSpeedX) - my._tm1 * 0.25);
//tD: note: the ball may slow down too fast
my._wSpeedZ = (-5 + my._pwSpeedZ) * my._tm1;
//tD: the ball may start to fall too fast
if (c_move (my, my._rSpeed, my._wSpeed, ignore_passable) <= 0.01) {
break;
}
wait (1);
}
}


Posted By: demiGod

Re: accurate shot - 08/17/07 18:04

It doesnt work either...

I believe this isnt such a complicated question, any ideas?
Posted By: quasarchangel

Re: accurate shot - 08/17/07 18:44

Isnt it because the ball gets created inside the player/gun model while player is moveing and therefore it, the ball, cannot move properly?
Posted By: demiGod

Re: accurate shot - 08/17/07 18:56

Hmmm, the ball is created and attached in a vertex at front of weapon pipe / barrel, but i tested before ballīs creation the gun is passable and the problem persists.

I realised that the weapons AUM worshops (58 and up) works great because the player moves slow, if increase speed it happens the same problem.

I think its necessary to consider the player speed at the moment...
Posted By: demiGod

Re: accurate shot - 08/17/07 20:32

Here is a little vid where we can see the problem that occours when player is moving:


SHOT PROBLEM HERE
Posted By: quasarchangel

Re: accurate shot - 08/17/07 22:18

I have come across this same problem before. It must be the player walking into it. Unfortunately I could never come up with a solution. Maybe you can try something with push values?

EDIT | What about just doing a precalculated shot with a trace and then moving the passable ball as one would expect, with gravity, etc? Probably would be hard to do.

Another thought...
Are you using the physics engine for the ball? If so you can set the ball to ignore the player, if I remember corectly.

By the way your HUD models look quite nice.

2nd EDIT | It looks also like either your impact events for the ball are not correct or maybe glide is on?
Posted By: EpsiloN

Re: accurate shot - 08/19/07 12:28

Quote:


Code:

function create_balls()
{
proc_kill(4);
vec_for_vertex (temp.x, weapon1, 1465);
ent_create (ball_mdl, temp.x, move_balls);
}

function move_balls()
{
var ball_speed;
my.pan = camera.pan;
my.tilt = camera.tilt;
ball_speed.x = 50 * time_step;
ball_speed.y = 0;
ball_speed.z = 10 * time_step; // change this to 0
while (my != null)
{
c_move (my, ball_speed, nullvector, ignore_passable);
ball_speed.z -= 3 * time_step; //change this to = -3 * time_step;
wait (1);
}
}





© 2024 lite-C Forums