Alternate to physics bullet

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • 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.

  • 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.

    Please login to see this link.

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


    Sent from my iPhone using Tapatalk

    Custom A* Pathfinding in MMF2: Please login to see this link.
    Random Tile World Generation: Please login to see this link.

  • 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?

  • 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.

  • 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

    Custom A* Pathfinding in MMF2: Please login to see this link.
    Random Tile World Generation: Please login to see this link.

    Edited 6 times, last by Sumo (August 14, 2017 at 2:42 PM).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!