Restricting the player movement

Get help using Construct 2

Post » Wed Jan 09, 2013 7:39 pm

How do I restrict the player movement? I need the player only move along a track (like a rail) with multiple junctions. Any help? Thank you.
B
65
S
13
G
2
Posts: 969
Reputation: 6,732

Post » Thu Jan 10, 2013 12:21 am

I would suggest making your own movement events.

eg.
While Left Arrow is down
->Set X to Object.X-2

While Right Arrow is down
->Set X to Object.X+2
B
40
S
12
G
7
Posts: 603
Reputation: 7,646

Post » Thu Jan 10, 2013 7:38 am

Are you thinking something top down like a train track? or a left and right?

Either way the Bullet behaviour is a awesome for straigt forward limited movement. I have a top down shooter where I ended up using bullet for movement instead of 8way. The reason being was that i am planning to use a analog stick.

BULLET is awesome. Just have it that at the junction, use a collision/ocerlapping to change the direction of the bullet object.

if you do a picture or share a sample of your idea we can help a lot more :)
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Thu Jan 10, 2013 11:59 am

Hy guys

Thanks for the reply.

I intend to restrict a player movement only, forcing that he can only move along a narrow path (like a rail or track) with multiple branches (like a maze). This way, he can go back and forth from any direction, including diagonally if necessary. A simple example attached

Thanks


RenatoB2013-01-10 12:46:24
B
65
S
13
G
2
Posts: 969
Reputation: 6,732

Post » Thu Jan 10, 2013 12:28 pm

How about something like:

if NOT player.overlapping.path
stop movement
snap player to path

if player.overlapping.path
enable movement

You get the general idea :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Thu Jan 10, 2013 12:51 pm

Hi @vee41

This restriction should be mandatory and not optional. As I understand your suggestion, it seems that the player does need to try to follow the trail. Is it?
B
65
S
13
G
2
Posts: 969
Reputation: 6,732

Post » Thu Jan 10, 2013 2:35 pm

This is what I had in mind: http://dl.dropbox.com/u/19921470/rails_example.capx

It 'sort of' works, what it needs to make it usable is proper turns and stuff. It's quite bad example really, just something I threw together to show what I meant :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Thu Jan 10, 2013 3:27 pm

Thanks for the example, @vee41.

I get it, but it seems not work in diagonally. Is this the best solution?
B
65
S
13
G
2
Posts: 969
Reputation: 6,732

Post » Fri Jan 11, 2013 7:00 pm

I did some experiments with the 8-directions behavior and works too (I wonder why use the bullet instead of 8-directions). The problem is that the player is not stuck to the rail and does not change direction smoothly in perpendicular movements. If I move the playe horizontally and pressed the UP / DOWN in the middle of the line, the sprite loses the path reference and doesn't move anymore.

Sample: http://dl.dropbox.com/u/72651057/rail_test.capx

Please some more ideas and suggestions.

Thanks
B
65
S
13
G
2
Posts: 969
Reputation: 6,732

Post » Sat Jan 12, 2013 1:58 am

Have you tried using solid invisible blocks to create a invisible barrier around each track? You can then set up custom movement or 8 directional, or even bullet. Car movement might be what you want for a train game though

[QUOTE=RenatoB] I did some experiments with the 8-directions behavior and works too (I wonder why use the bullet instead of 8-directions). The problem is that the player is not stuck to the rail and does not change direction smoothly in perpendicular movements. If I move the playe horizontally and pressed the UP / DOWN in the middle of the line, the sprite loses the path reference and doesn't move anymore.

Sample: http://dl.dropbox.com/u/72651057/rail_test.capx

Please some more ideas and suggestions.

Thanks
[/QUOTE]
B
18
S
4
G
3
Posts: 436
Reputation: 4,801

Next

Return to How do I....?

Who is online

Users browsing this forum: mercuryus and 13 guests