How do I spawn an object on different object?

0 favourites
  • 2 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hey! I'm making a game (tower defense) and when when I drag a tower over an area and drop it there, it's suppose to spawn a new object on the area(which is a sprite), but the problem is that if it's over two of the same areas, I don't know which one it's gonna land on. Can someone help me?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey! I'm making a game (tower defense) and when when I drag a tower over an area and drop it there, it's suppose to spawn a new object on the area(which is a sprite), but the problem is that if it's over two of the same areas, I don't know which one it's gonna land on. Can someone help me?

    The best and easiest way to solve this is to use a pick nearest/furthest action, when you drop the tower on the sprite where you want to spawn it. I guess you have some conditions that when you drop the Tower you want to place, you also check whether its overlapping this sprite where you can place it.

    Now if the Tower overlaps several sprites your pick counter of those sprites is likely to be greater than 1, but since you are also for certain closer to the sprite where you actually want to place the tower than those where you don't want to. You can use the pick nearest/furthest action to pick the sprite closest to the Mouse.X, Mouse.Y.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)