# mine car as moving platform - slopes?

• 29th December 2015, 05:05 PM
Wodjanoi
mine car as moving platform - slopes?
I have a mine car that works like the moving platforms of DaveC's Kid Icarus Example.
In my little game the mine car only moves, if the player character is on top of it.
For the car movement I just use the basic code:
X position to X object position +1
or for a slope:
X position to X object position +1 and
Y position to Y object position -1

But if I don't want to change the speed I have only one angle I can use for slopes.
How can I determine movement angles for different slopes without using X position X +1 and Y position Y -1?
• 29th December 2015, 05:57 PM
King_Cool
I'm not sure if this is what your looking for.

Say you have a Cart following an irregular shaped track ( like a hand drawn curve )

- First of you'd want the cart to be able to move along the track
- If you have the above working, you would also want the Carts Angle to follow the angle of the tracks it's currently standing on ( cuz it looks silly if the Cart is always looking to the right )

This method will get you the Angle of the track the Cart us standing on:

- When the cart is standing on the track, position 1 detector at the left side/ wheel of the cart, and 1 detector at the right side/ wheel.
- Then run loops for the detectors, moving them 1px down until they hit ground.
- After the loops end, the Angle between the two detectors will be the angle of whatever slope the Cart is standing on.
• 29th December 2015, 07:25 PM
Scilya151
if its a track and you know the angle of the slope you can test for entering an area and change the angle that way. you can set the angle to increment at a set ammount to smooth it out.

wait do you just want to find out what the angle of a slope is?
• 29th December 2015, 10:59 PM
casleziro
King_Cool's method is the most accurate/correct way. If you want to cheat, though, and have set ground angles that the cart follows you can just place invisible actives along the track that change the cart's angle when it runs over them. Then regardless of what method you use to find the angle, you use some math to move the cart towards it.

In my example, you set the player angle from 0-360 and it'll move towards it. 0 is straight right, 180 straight left, 90 straight up, 270 straight down, etc.

Attachment 18643
• 4th January 2016, 11:18 AM
Wodjanoi
Thanks for the examples.
In my case I don't want to change the angle of the car.

Okay I got something:
Attachment 18710

I want to use the code for an Android game but it doesn't work like expected.
Android doesn't like my code.(Maybe PMO Object in combination with custom gravity causes the issues?)
I hope somebody can explain to me why Android doesn't like my code.

Attachment 18712
• 4th January 2016, 10:20 PM
Wodjanoi
I write my code again step-by-step and everything works fine now.
I don't know the issue, but it doesn't matter. I assume something in my old mfa file messed up.