# How do I limit player interaction within a certain radius

0 Favourites
• 7 posts
• The title of this thread isn't necessarily the greatest in terms of explaining what I'm trying to do, so I'll try to explain a bit better.

If you've ever played a game like Terraria, you know that the player can only break blocks within a certain distance from the player (which (I think) can be altered depending on the tool/weapon you are holding).

I'm wondering how to do this myself. Below is a link to my current capx proof of concept file. Currently, no matter where the player character is standing, one can click on any of the resource blocks and collect them at will. I would like this to change so you can only collect blocks within a certain radius of the player that is reliant on the tool the player is using (I have not yet implemented tools yet but this is my end game so a small explanation for that would be amazing).

• ..add another condition...

System..compare two values.... distance(Player.X.Player.Y.Ground.X,Ground.Y) is less than ...

• you could also do this with line of sight

• Change the Line of Sight to custom, then distance of line of sight is in pixels

• Change the Line of Sight to custom, then distance of line of sight is in pixels

Line of sight was what I tried at first, but I couldn't get it to work for the life of me. But I see now setting it to custom is what I was missing. Thanks!

..add another condition...

System..compare two values.... distance(Player.X.Player.Y.Ground.X,Ground.Y) is less than ...

Thanks for this! Super easy, I'm kind of new to the program and I learn better by example so this helps a ton. (:

• No prob...

You do not have to use hard number(100 ) ...you can add variable let say " MaxRange= 100"

System..compare two values.... distance(Player.X.Player.Y.Ground.X,Ground.Y) is less than " MaxRange"

and now you can increase or decrease " MaxRange"

if something add to " MaxRange" 50 or...

• ## Try Construct 3

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

Construct 3 users don't see these ads
• Yeah! I can see how setting it to a Global variable and then simply setting an event that checks different tools instanced variables and assigning the value of the global variable to the tool's range variable would allow for an increase or decrease in distance. Awesome.

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