How do I lock an Object within boundaries of a Moving Object

Get help using Construct 2

Post » Sun Sep 06, 2015 4:40 am

Hey,

I am trying to make a train game, where the player can board a moving train. Right now the train is simply moving along a path continuously.

I want the player to be able to move around freely when on the train cart and as the train moves and changes directions, the player should move with it.

I tried to set the X and Y coordinates of the player to match that of the train, but of course this would mean the player is locked onto the train (and not able to move freely around the moving train cart the way that I want).

Does anyone have any ideas how this could be done?

Thanks in advance.

Dropbox (CAPX): https://www.dropbox.com/s/hxbw3paavdkpr ... .capx?dl=0
One Drive (CAPX): https://onedrive.live.com/redir?resid=7 ... ile%2ccapx

Best,
Adrian
Last edited by Badmiracle on Mon Sep 07, 2015 5:24 am, edited 4 times in total.
B
79
S
25
G
9
Posts: 85
Reputation: 9,280

Post » Sun Sep 06, 2015 10:20 pm

Need.. help... from.... those of superior intellect
B
79
S
25
G
9
Posts: 85
Reputation: 9,280

Post » Sun Sep 06, 2015 11:07 pm

maybe trying creating an invisible border that is solid and the player cannot collide with along the edges of the train?
B
3
Posts: 2
Reputation: 179

Post » Mon Sep 07, 2015 1:00 am

Although that would contain the player from being moved out of the train, that still wouldn't work because the player would constantly be being pushed to an end of the train depending on its direction.
B
79
S
25
G
9
Posts: 85
Reputation: 9,280

Post » Mon Sep 07, 2015 1:03 am

I was unable to download your capx. Could you reupload it or post it on Dropbox?
B
56
S
15
G
13
Posts: 826
Reputation: 17,665

Post » Mon Sep 07, 2015 5:17 am

Sure, sorry about that. Here is an updated link (but they both should work - that was odd).

Thanks in advance if you can figure it out!

https://www.dropbox.com/s/hxbw3paavdkpr ... .capx?dl=0
B
79
S
25
G
9
Posts: 85
Reputation: 9,280

Post » Mon Sep 07, 2015 3:50 pm

Bump
B
79
S
25
G
9
Posts: 85
Reputation: 9,280

Post » Mon Sep 07, 2015 4:06 pm

This isn't a real solution, but it works, a litte bit. As long as your player is on the origin of your 'train' it works.
But if not and the train turns you will fall of and I don't have any solution for this. I tried a rotation matrix to calculate the postion of the player when the train turns but that doesn't work.

In your every tick event

System every tick -> Player set angle Train.angle
" " -> Player Move forward Train.Pathfinding.Speed*dt
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Mon Sep 07, 2015 6:37 pm

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 » Mon Sep 07, 2015 7:11 pm

Asmodean - good attempt I like what you were thinking but unfortunately this locks the players Angle to the Angle of the Train.

LittleStain wrote:Does this solve your problem?

https://dl.dropboxusercontent.com/u/485 ... oved1.capx


LittleStain thank you! You've solved a huge problem for me. I initially had a similar idea to use the Train objects OldX and OldY but I couldn't for the life of me figure out how to work out the changing of the angles. Thanks again!
B
79
S
25
G
9
Posts: 85
Reputation: 9,280


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests