Navigation

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

    Problems with collisions

    Beginners
    collision help
    7
    36
    2355
    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.
    • waldron
      waldron F last edited by

      Hi if you just want the collision so it stops the player the collidesprites has this inbuilt already.
      collide = collidesprites(sprite, wall) , true , false )
      if you wanted to have more effects to happen after that you would use detectspritecollision using an if statement(something..something happens) ect which i would be happy to go into more detail but for now that will do what your after.

      1 Reply Last reply Reply Quote 2
      • landein207
        landein207 last edited by

        Thanks for helping me for me collisions are very dificult to understand i will check if that works thanks a lot :)

        1 Reply Last reply Reply Quote 0
        • landein207
          landein207 last edited by

          my player still pass through the wall :P

          Jongjungbu 1 Reply Last reply Reply Quote 0
          • Jongjungbu
            Jongjungbu F @landein207 last edited by Jongjungbu

            Once you have collided sprites, you could use the resolution vectors to do extra effects.
            This is what I did for moving platforms you walk on. But note that collidesprites will only stop the player if you're using setSpriteSpeed(), whereas setSpriteLocation() can actually override this (at least temporarily).

            collide = collidesprites(player.sprite, platform.sprite, true, false )
            if collide.exists then // collision happened between the two
            if collide.resolution_a.x>0 then // it pushed the player to the right
            // do something
            endif
            endif

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

              Hmm maybe the problems im having with collisions is because i have sprite speed and and sprite location at the same time

              1 Reply Last reply Reply Quote 2
              • landein207
                landein207 last edited by

                Ok after a bit i found that the wall location need to be out of the loop to be honest i don't know why it won't work with both locations in the loop :P

                1 Reply Last reply Reply Quote 1
                • Jongjungbu
                  Jongjungbu F last edited by

                  What do you mean by wall location in the loop?

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

                    The setspritelocation(wall,625,550) but it collides but like a moveble box instead of a place you can't pass it is weird how collisions work is anygame out there that works the map with collidesprites()
                    instead of collidemap or collidemaparea to see if i can learn how can i do what i want with my game =/

                    1 Reply Last reply Reply Quote 0
                    • Jongjungbu
                      Jongjungbu F last edited by Jongjungbu

                      When you use collideSprites(), make sure you set 3rd or 4th argument values to 'false' or it will be a movable box.
                      For instance,
                      collideSprites( player, wall, false, false)
                      The default I believe is for those two 'false' arguments to be 'true'. When the first is true, then the player will be moved. When the second is true, then the wall can be moved.
                      When both are 'false', then neither can push one another, but they also can't pass through each other.

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

                        In my game when both are false the player passes through the wall idk what to do now :P

                        1 Reply Last reply Reply Quote 0
                        • Jongjungbu
                          Jongjungbu F last edited by

                          Is your player movement code via setSpriteLocation() or setSpriteSpeed()?
                          Where is your collideSprites() sitting? This should come shortly after your movement code, in my experience.

                          1 Reply Last reply Reply Quote 0
                          • landein207
                            landein207 last edited by

                            Setspritelocation i removed the setspritespeed and i placed the colidesprites before the player movement code let me test is changing the place of the colidesprites can change the problem
                            Edit: still don't working :P

                            1 Reply Last reply Reply Quote 0
                            • Jongjungbu
                              Jongjungbu F last edited by

                              I have found setSpriteLocation() can override the collision. When using that function, I need to instead detectSpriteCollision(), I think that's the right one, and then move the player myself if detected. It won't naturally block him from moving.

                              If using setSpriteSpeed() then follow it with collideSprites(), it will naturally block the player from moving.

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

                                But i think with the setspritespeed i can't make playet controls so i probably will need search a bit to find how to use the detectspritecollision :P
                                But thanks that helps me a lot and probably in future fuse updates see if is possible correct that problem with the sprite location and sprite colision

                                waldron 1 Reply Last reply Reply Quote 1
                                • Jongjungbu
                                  Jongjungbu F last edited by

                                  I think that works as intended. You have one way, where Fuze detects and you code the effects. Maybe you want to bounce the player or teleport him. The other is use Fuze built-in effect of blocking pathing.

                                  1 Reply Last reply Reply Quote 0
                                  • waldron
                                    waldron F @landein207 last edited by

                                    @landein207 i think its just a matter of getting used to how you set out code, il be less busy tomorrow if you wanted me to share a program demonstrating how to work with collision ?

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

                                      Yes plz that may help me

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

                                        Ok i was testing the controls with setspritespeed instead of setspritelocation the collision works but the movement looks like sliding in ice.
                                        how can i avoid that effect in the movement?

                                        1 Reply Last reply Reply Quote 0
                                        • PickleCatStars
                                          PickleCatStars F last edited by

                                          I’ve never used setspritespeed, so I don’t know the exact way, but if you ’spritespeed *= 0.8’ at the end of your loop somewhere, that’ll work like friction..

                                          1 Reply Last reply Reply Quote 0
                                          • landein207
                                            landein207 last edited by

                                            I think i will open a new topic for that but thank you for the friction 'command'

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