Distance restrictions

Get help using Construct 2

Post » Wed Oct 15, 2014 3:21 pm

I got a problem here mates, I'm working with a sprite(lets call it "amigo") whose coordinates are related to the mouse coordinates, and that sprite has to be restricted in a circular area.

Suposing that there is a sprite ("chain") whose coordinates are the center of the circunference, How Can I make that if "amigo" gets x distance away from "chain", "amigo" gets restricted in that circular area.
I'm letting here a picture that I hope it helpsMuch thanks people!
You do not have the required permissions to view the files attached to this post.
Last edited by Karapan on Wed Oct 15, 2014 3:30 pm, edited 2 times in total.
B
4
Posts: 9
Reputation: 218

Post » Wed Oct 15, 2014 3:23 pm

If you need some help, first change your post title to something that will describe your issue.
ImageImageImageImage
B
158
S
66
G
43
Posts: 2,603
Reputation: 35,868

Post » Wed Oct 15, 2014 3:31 pm

shinkan wrote:If you need some help, first change your post title to something that will describe your issue.

Aww sorry, its my first post and I forgot it :/
B
4
Posts: 9
Reputation: 218

Post » Wed Oct 15, 2014 6:35 pm

Someone with more knowledge can correct me, but I believe you will need to have a physics object for each link in your chain, then create a distance joint between all the links. This will make your "amigo" move around inside any given radius, while restricting it going any further. Make "chain" unmovable" and attach "amigo" to the mouse position.
I don't know if that helps or not as I'm just thinking off the top of my head.
Be sure to check out my Metroidvania game, A Hole in the Earth
B
59
S
24
G
3
Posts: 359
Reputation: 5,683

Post » Wed Oct 15, 2014 6:37 pm

I can think of the pin behavior, in "Rope" mode, if you do not need physic interactions, that would work
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Thu Oct 16, 2014 3:39 pm

Simple trigonometry with the clamp expression will also help you. See example.

I also included a pin example.
You do not have the required permissions to view the files attached to this post.
B
74
S
31
G
26
Posts: 994
Reputation: 20,198


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 11 guests