The Daily Click ::. Forums ::. Klik Coding Help ::. Bullet collision
 

Post Reply  Post Oekaki 
 

Posted By Message

Aptennap



Registered
  23/04/2004
Points
  916
6th March, 2009 at 22:31:11 -

If I'm using : always set xvel("bullet") to xvel( "bullet" )+Cos(Angle( "bullet" ))*50 set xpos to xvel etc. for bullets, then how would I check for bullet overlapping? Cause if I just do if bullet is overlapping backdrop then the bullet might go over the backdrop because it skips so much space. I'm guessing I would need to use fastloops, it's for an online game (does that make a difference?).

EDIT : Also how could I do collision testing for a 360 movement (like GTA 1 and 2).

Edited by Aptennap

 
Oh sweet mary.

dndfreak



Registered
  11/01/2009
Points
  650
7th March, 2009 at 04:18:58 -

Im not sure about the first question but i have a method for the second one. I think there's a better way to do this but it still works.

I'm assuming you mean collides with front, side or back, right? I put however many objects you need under the player, then have collisions for each of them. For example, let's say you have four animations for death depending upon what side your guy was shot from. So take your guy (lets make him circular) and put four quarter-circles underneath. One faces front, one back, and the others left and right. Give each the same movement as the player so that they stay proportionate. Then have four collision statements with the bullets but instead of using the player object use the pie pieces. If they're killed from a shot to the back, play the appropriate animation, the same goes for the others.

I hope I helped you out here.

 
Vegeta? What does your mother say about my power level?

ITS OVER 9000!!!

Aptennap



Registered
  23/04/2004
Points
  916
7th March, 2009 at 11:09:17 -

Thanks, that helped .

 
Oh sweet mary.

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
7th March, 2009 at 12:52:11 -

You can run a fastloop to move the bullet in smaller increments.
In the example below, the bullet checks for collisions every 5 pixels, but the bullet still moves at the right speed because the movement loop is repeated 10 times per frame.

+ always
-> start loop "move" 10 times

+ on loop "move"
-> set xpos("bullet") to xpos( "bullet" )+Cos(Angle( "bullet" ))*5
-> set ypos("bullet") to ypos( "bullet" )-Sin(Angle( "bullet" ))*5
-> set x to xpos
-> set y to ypos

+ on loop "move"
+ bullet overlapping
-> stop loop "move"
-> other stuff...

You could move the bullet in increments of a single pixel (replace "10" with "50", and "5" with "1"), but this would be inefficient.

Or just to use the MoveSafely extension.

As for detecting the relative angle of collision, read this thread: http://www.create-games.com/forum_post.asp?id=244612

 
n/a

Aptennap



Registered
  23/04/2004
Points
  916
7th March, 2009 at 13:18:36 -

Thanks. What if there are more than one bullet at a time, will this work then?

 
Oh sweet mary.

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
7th March, 2009 at 13:36:11 -

yeah, just get rid of the "stop loop: move" action - you don't need it anyway.

 
n/a

Aptennap



Registered
  23/04/2004
Points
  916
7th March, 2009 at 13:47:48 -

Oke thanks! (word word)

 
Oh sweet mary.

tetsuya_shino



Registered
  12/08/2004
Points
  491
8th March, 2009 at 01:17:59 -

Greetings. While we are on the subject of bullets, I had a quick question. I want to shoot a bullet like object which will cause an event when it connects. The problem is that I only want it to hit one enemy. I know there is a trick if you are working with clones, but all my enemies have different file names. Any ideas? Thanks.

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
8th March, 2009 at 01:35:19 -

Use the move safely 2 object. You can keep your normal shooting code and it can find if your bullets would have gone through walls, stopping them in the right place. There are example included which show you exactly how to use it.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

tetsuya_shino



Registered
  12/08/2004
Points
  491
8th March, 2009 at 01:41:33 -

er, I'm using tgf

 
n/a
   

Post Reply



 



Advertisement

Worth A Click