How do I limit player interaction within a certain radius

Get help using Construct 2

Post » Sat Apr 25, 2015 12:00 am

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).

https://drive.google.com/file/d/0B_fsFsHtHjNqVkVNX0tVVGJhYlU/view?usp=sharing
B
5
Posts: 19
Reputation: 263

Post » Sat Apr 25, 2015 12:30 am

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

Image
B
66
S
24
G
7
Posts: 1,514
Reputation: 11,039

Post » Sat Apr 25, 2015 12:35 am

you could also do this with line of sight
B
11
S
1
Posts: 57
Reputation: 664

Post » Sat Apr 25, 2015 12:41 am

Image

Change the Line of Sight to custom, then distance of line of sight is in pixels
B
11
S
1
Posts: 57
Reputation: 664

Post » Sat Apr 25, 2015 12:45 am

Tryitoutkris wrote:Image

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!

korbaach wrote:..add another condition...
System..compare two values.... distance(Player.X.Player.Y.Ground.X,Ground.Y) is less than ...

Image


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

Post » Sat Apr 25, 2015 12:57 am

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...
B
66
S
24
G
7
Posts: 1,514
Reputation: 11,039

Post » Sat Apr 25, 2015 1:01 am

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.
B
5
Posts: 19
Reputation: 263


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, ignaciosimo, nickar and 40 guests