Results 1 to 8 of 8

Thread: Alternate to physics bullet

  1. #1

    Alternate to physics bullet

    Hello all, I am trying to fire a bullet, pretty simple but using the bouncing ball object only allows for 32dir so the aiming becomes inaccurate. The other option is a physics bouncing ball, this can fire at an angle but I didn't want to use it due to performance loss, compared to the normal bouncing ball. Any one got any ideas? I couldnt do math either because of certain ramifications.

  2. #2
    When you launch the bullet, set the angle to the angle the object that is launching the bullet


    Sent from my iPhone using Tapatalk

  3. #3
    yeah but a bouncing ball doesn't fire using angles. Did you mean using the "launch an object" function?

  4. #4
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    622

    Alternate to physics bullet

    The best method is using trigonometry to make your bullets move in full 360 degrees so it's always accurate. What "certain ramifications" are you talking about that won't let you do math? It should be fine on all exporters.

    http://www.create-games.com/article.asp?id=1322

    The first part of the article talks about what you need.


    Sent from my iPhone using Tapatalk

  5. #5
    Hello thanks so much, the ramifications were mainly to do with collision. The collision seems to be much worse using 360degree shooting obviously it is better with slower traveling bullets but I would like them to be faster. Any ideas?

  6. #6
    Sorry, i should add, i = need the precision to be accurate because when the bullet hits something a smaller bullet is created at the point of impact, it is a physics object so if it spawns whilst the bullet is on the wall it also remains on the wall.

  7. #7
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    622

    Alternate to physics bullet

    Ah, then you should use fastloops to move the bullets 1 pixel at a time so you can check for perfect collision no matter the speed of the bullet.

    First you need to make sure your player is rotating a full 360 degrees. You would change the angle of the player active to the vector angle between two objects (under the active > position submenu) during an Always condition. For the other object you're looking at, you could use the mouse xmouse and ymouse for example.

    So you can use two alterable values within your bullet called XMove and YMove. When you shoot, you create a bullet at your player and set the angle of the bullet to your players angle, and set the XMove alterable value to the current X position and set the YMove alterable value to the current Y position.

    Normally you would use an Always condition to move the bullets.

    Always:
    Add Cos(angle of bullet)*10 to XMove
    Add Sin(angle of bullet)*-10 to YMove
    Set bullet X position to XMove
    Set bullet Y position to YMove

    The 10/-10 at the end of the equation is how fast the bullet will move in pixels. So if we're modifying this with perfect collision we will need to move the bullet 1 pixel at a time.

    So start an Always condition that will begin a fastloop "move bullets" for X number of loops. The number of loops you run will be how fast you want the bullet to move. So you can set it to 10.

    On loop "move bullets":
    Add Cos(angle of bullet)*1 to XMove
    Add Sin(angle of bullet)*-1 to YMove
    Set bullet X position to XMove
    Set bullet Y position to YMove

    Therefore on one loop of the fastloop it will move the bullet one pixel at a time. It will then do this 10 times, so overall it will look like the bullet is moving at a normal speed of 10 pixels.

    Add another on loop "move bullet" condition in a new line to test for the collision.

    On loop "move bullets":
    Bullet is overlapping wall:
    Destroy bullet.

    This will be tested during the fastloop after it moves the bullet 1 pixel at a time. Therefore it won't matter how fast your move your bullet by modifying the number of fastloops your run. It should always destroy the bullet whenever it hits the wall.

    This should give you the flexibility of 360 degree shooting with perfect collision detection for your bullets so you can shoot them at any speed. Just make sure you're only moving the bullets 1 pixel at a time in the fastloop and instead if you want to change the speed, you change the number of loops the fastloop runs for.

    Sent from my iPhone using Tapatalk
    Last edited by Sumo; 14th August 2017 at 01:42 PM.

  8. #8
    Thanks a lot.

Similar Threads

  1. Overlapping, Raycast and Bullet Physics
    By Matheus290 in forum Firefly
    Replies: 4
    Last Post: 30th June 2017, 07:13 PM
  2. Bullet Physics with Physics - Engine
    By Spykid in forum Fusion 2.5
    Replies: 4
    Last Post: 7th November 2015, 12:07 PM
  3. Replies: 2
    Last Post: 27th May 2015, 08:24 AM
  4. Bullet bug with Physics and Android
    By isoetes in forum Android Export Module 2.5
    Replies: 1
    Last Post: 2nd May 2014, 05:48 PM
  5. [BETA] OpenGL - Bullet Physics
    By Algul in forum Extension Development
    Replies: 13
    Last Post: 14th November 2011, 08:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •