static object moves

themadjulithemadjuli Posts: 4Member
edited November 2018 in 2D

hi everyone,

i want to make a game, where a ball is moving in random directions through a small map. in this map i want to build shapes f.e. sqauares. i made it possible to get the ball moving random. unfortunately the squares are moving too. how is it possible to get them static?

thanks for every advice

3.PNG 140.3K
2.PNG 73.1K
4.png 35.6K


  • TwistedTwiglegTwistedTwigleg Posts: 1,000Admin
    Answer ✓

    Looking at the scene, the reason the box is moving is because it is a child node of the Ball node, and since the Ball node is moving, all of its children nodes will move too.

    There are a few easy fixes. The easiest fix is to simply make a new scene with the box and set it up as you have it in the ball scene. Then make another new scene and instance both the ball scene and the box scene into that. Then the ball will be able to move without moving the box since the box will not be part of the ball scene.

    The other way to fix the problem is instead of directly modifying the position of the Ball node, instead modify the position of only the nodes responsible for the ball itself. Looking at the pictures posted, it looks like Area2D will mpve the ball and its sprite, without moving the box. Personally, I would not use this fix and instead use the fix above as it will be easier to manage as your game gets larger, but depending on what the box is supposed to do it may make more sense to have it part of the ball scene.

    Regardless, either moving the box out into its own scene or only moving the ball related nodes should fix the problem. Hopefully this helps :smile:

  • themadjulithemadjuli Posts: 4Member
    edited December 2018

    thanks, thats it! now i have the problem, that the ball moves through the square. oh man :D

Sign In or Register to comment.