make object events wor if something else is nearby

0 favourites
  • 3 posts
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • Hi,

    I am building an adventure point and click game, in the game there will be a lot of objects for the player to interact with. What I want is for the object to only be clickable and useful when the player is near the object.

    My initial idea was to create an invisible object that acts as an area of effect, so if the player is overlapping that radius object then the item becomes clickable... But that would require lots of extra objects being added to the layout.

    As the game will have a lot of objects that the player can interact with is there a better way of doing this that doesnt require adding objects to the layout as I want to improve the games efficiency as much as possible.


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are some situations where trigger objects are the way to go, but for what you describe you can use the distance expression to see if the player is within a certain distance of the other thing. Create a system event using the compare two values condition:

    system-> distance(player.x,player.y,thing.x,thing.y)<=thing.reach

    where reach is an instance variable created on the thing object(s) that contains how close to the thing the player has to be to reach it to interact with it.

    At first I thought it would be better to put "reach" on the player, but you may have to be closer to some objects than others, so it would be better to have it on the thing.

    If you have many different kinds of objects, and are using the paid version you can put all of your interactive objects in a family and create the "reach" instance variable on it. Otherwise you'll have to create the "reach" instance variable on each type of object you want the player to interact with in this way. But that is a lot better than having to create a bunch of trigger objects!

  • That is perfect thank you, I am using the paid so will probably use the families as you suggested. Thank you that should greatly improve the performance and be much easier to alter as needs be.

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