why do my bullets SOMTIMES miss??

Game Editor comments and discussion.

why do my bullets SOMTIMES miss??

Postby PooAs » Sun Apr 20, 2008 7:08 am

i have an enemy actor
who creates the actor bullet
the bullet:
draw actor- xvelocity = xvelocity + 15;
...
somtimes it hits the player somtimes it doeant?
does it have somthing to do with the speed
how can i prevent this?
If you try
to fix violence
with violence
you do nothing
but create violence
User avatar
PooAs
 
Posts: 29
Joined: Thu Apr 03, 2008 10:24 am
Score: 3 Give a positive score

Re: why do my bullets SOMTIMES miss??

Postby DST » Sun Apr 20, 2008 8:14 am

yes it has everything to do with speed. I believe its the framerate problem - notice how the bullet doesn't draw in every xposition on the game, but rather 'teleports' from one location to the next? Well if the player was in the empty space between teleports, then the bullet never touched him.

Some simple solutions to this are to increase the framerate to 60 fps and reduce your velocity by half; everything will appear to be the same speed, but this will reduce the gaps between teleport locations, as the bullet will be drawn twice as often.

Using a thicker player, in addition, will increase chances of collision.

Another method used in modern games is to create a wireframe actor, and attach it to the bullet. This invisible actor will extend behind the bullet, turning in into more of an 'arrow'. if the wireframe is long enough, it will reduce the teleport gap to 0, and the collision will always happen. The downsides to this method are:
The wireframe is an extra actor to create and destroy, and you will have to remap your collisions to this actor and not the bullet.
There is a chance that the bullet itself may be on the other side of the player and had time to render 1 frame before the collision happens. But at least the collision will happen.
Also, it can sometimes be difficult to troubleshoot when using wireframe actors because you can't see them during gameplay, so its hard to know for sure what they're doing.
And, of course, its possible to be killed by a bullet that looks like it never touched you, like if you fell onto the wireframe but the bullet was already moved. Of course, if your bullet is moving fast enough to have this problem in the first place, then player 1 probably can't fall or jump fast enough to collide this way.

There many other methods, but most of them far more complex than any of these. Try the first two hear and see if you can't make it work right.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: why do my bullets SOMTIMES miss??

Postby PooAs » Sun Apr 20, 2008 9:14 am

thanks man :)
i used the frame rate one works good but..
now when i jump it jumps faster and beats my wireframe that moves the view?
and sometimew when i am walking there a frames where he walks faster??
If you try
to fix violence
with violence
you do nothing
but create violence
User avatar
PooAs
 
Posts: 29
Joined: Thu Apr 03, 2008 10:24 am
Score: 3 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron