Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Help with collision

    Help
    2
    3
    227
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • poof92
      poof92 last edited by

      Have no idea how to do this but I'm trying to make a space ship shooter I've got the movement down and kinda the shooting but I want the ship to collide with the player or vice versa and I want the ship to be destroyed im gonna keep trying but any help would be useful.

      1 Reply Last reply Reply Quote 0
      • Dave
        Dave Fuze Team last edited by

        You've got lots of different ways to do it.

        Are you making a 2D game or 3D? Are you using the sprite commands or just using drawImage(), etc?

        Depending on how you're making this game, different methods of collision might be best.

        The quickest, simplest, and also least accurate way would be to use distance.

        dist = distance( shipPositionVector, playerPositionPlayer )
        if dist < x then
            // here is where you want to do the collision result. So, health decreases or ship is destroyed etc.
            // Remember, if you have multiple ships to collide with this will need to be a For Loop which counts over ever ship.
        endif
        

        There's an instance of this in the Sprite Game tutorial, but using the sprite commands:

         72.         if distance( playerPos, rocks[i].pos ) < rockSize.x / 2 - 50 and alive then
         73.             alive = false
         74.             setSpriteAnimation( expSpr, 0, 89, 14 )
         75.             setSpriteLocation( expSpr, playerPos )
         76.             setSpriteScale( expSpr, scale )
         77.             setSpriteVisibility( expSpr, true )
         78.             setSpriteVisibility( playerSpr, false )
         79.         endif
        

        From this tutorial page: https://fuzearena.com/help/view/Sprite Game

        Let me know if you need anything else! I'm sure lots more people will have better ideas. The other, more accurate way of doing it is with a series of If statements.

        1 Reply Last reply Reply Quote 1
        • poof92
          poof92 last edited by

          It's a 3d game

          1 Reply Last reply Reply Quote 0
          • First post
            Last post