How do I keep a player "on rails"?

Get help using Construct 2

Post » Thu May 14, 2015 3:10 pm

I'd like to create a game in which the player object can be touched and dragged around a circle, but not off-circle. So, effectively, the circle acts as a "rail" that the player is locked to and can navigate freely, but only left or right around the outline.

Can anyone offer any advice on how to make something like this work?
B
14
S
2
Posts: 73
Reputation: 794

Post » Thu May 14, 2015 3:38 pm

There's a few ways of handling this depending on the specific behaviour you're after. Do you want the player to be able to move freely inside the circle, or only around the outside of the circle?

If the player can move freely within the circle its quite simple, use this event, just make sure to doublecheck the image point of the player character and collision polygon of the circle.

http://imgur.com/vDeDxdQ

If you want to have the player only able to move around the outer edge, I would create a second smaller and invisible circle sprite, and place it inside the first circle, again making sure the collision polygon fits, and edit the event like this :

http://imgur.com/FF7JADV

Hope that helps!

EDIT : For some odd reason the forum doesn't like my images, put links to them in instead.
Intermediate level Construct 2 developer, looking to build up my portfolio : https://seriouslycrunchy.itch.io/

Current projects : Bite Sized Game Development, please have a look at my tutorials and comment!

I also write for http://moonbooks.net/, please come and check us out!

Follow me on twitter! @SrslyCrunchy I'm always looking for games or templates to highlight, use the hashtag #madeinconstruct !
B
15
S
6
Posts: 52
Reputation: 3,006

Post » Thu May 14, 2015 3:46 pm

you want the player to follow the mouse and also stay in the circle edges?? that example above only allows you to move the player when the mouse is touching the circle, but you could do it easy , by creating a more complex edge detection with position and distance of the character based on bbox ,left right top down, of the circle, and then you could click anywhere on screen if you want to.
B
70
S
20
G
67
Posts: 1,311
Reputation: 42,293

Post » Thu May 14, 2015 4:51 pm

I want to have multiple players able to move their own objects along the rail (on a touch screen device), so I won't be using the mouse object.

I also want to have the object actually move along with the player's finger, perhaps with a bit of leeway so it can continue moving even if they get a little ahead of the object itself (I could do an "Is touching object", but the movement stops immediately if the player isn't right on top of it the whole time).

I think your examples with the two circles is pretty helpful if I make the size difference very minimal (I really want zero forward or backward wiggle room...only sliding left or right down the "rail"),
B
14
S
2
Posts: 73
Reputation: 794

Post » Thu May 14, 2015 5:51 pm

I would go for something like this:

https://dl.dropboxusercontent.com/u/485 ... ircle.capx
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu May 14, 2015 6:12 pm

Message: donkeyspaceman is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
LittleStain wrote:I would go for something like this:


This is exactly what I was looking for! Thank you! :D
B
14
S
2
Posts: 73
Reputation: 794

Post » Thu May 14, 2015 9:42 pm

Message: donkeyspaceman is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
LittleStain wrote:I would go for something like this:



Wait, I lied! There's still an issue with this one, but hopefully you can help me figure it out.

When I try this on a touch device, I can move one circle fine, but touching the second one immediately jumps it to the position of the first touch. I'd like to link the separate instances of these sprites to whatever touchID touched them last, so multiple players can move multiple sprites at the same time independently.
B
14
S
2
Posts: 73
Reputation: 794

Post » Fri May 15, 2015 1:02 am

Actually im wrong, still doing the jumping thing you talking about, tried with a tx ty but cant really figure it out now :D im out of this topic :D gluck
B
70
S
20
G
67
Posts: 1,311
Reputation: 42,293

Post » Fri May 15, 2015 6:59 am

Ah, ok.. can't test on mobile now, but my implementation of the touchID leaves something to be desired..
try this:

https://dl.dropboxusercontent.com/u/485 ... uchID.capx
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri May 15, 2015 1:53 pm

Message: donkeyspaceman is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
LittleStain wrote:Ah, ok.. can't test on mobile now, but my implementation of the touchID leaves something to be desired..
try this:


Still behaving the same. I tried doing something similar with picking events but it also didn't seem to work.
B
14
S
2
Posts: 73
Reputation: 794

Next

Return to How do I....?

Who is online

Users browsing this forum: JaredX, ksiads, Magistross, Rable and 6 guests