Change player angle according to the slope

Get help using Construct 2

Post » Wed Feb 19, 2014 11:32 am

Hi

I have searched for this topic, but didn't find much. I'll try to explain what I m looking for.

For e.g. If I have a running horse and I want it to change its angle according to the slope(solid) on which it is placed. Like if its climbing a mountain, it's angle should change according to the mountain and it should tilt, In my case the horse just stays straight throughout.Can anyone please explain how this can be done??

Thanks
B
5
S
1
Posts: 16
Reputation: 408

Post » Wed Feb 19, 2014 12:20 pm

Hello karan316,

The first thing you need is for a given horse to know on what slope it is standing. All depends on how you display/create your slopes though, but we can assume the horse is overlapping with the floor. If so, an event "Horse is overlapping with Slope" could let you adjust the angle every tick.
Now that you know what slope the horse is currently on, you need to add some sort of variable on every slope that stores the angle at witch the horse should be when it is there. Let's say you have this variable "horseAngle" on the Slope object.
Now your event is :
Horse is overlapping with Slope => Horse set Angle to Slope.horseAngle

Of course, you will need to prepare this variable on each and every slopes.
B
17
S
8
G
4
Posts: 473
Reputation: 6,221

Post » Wed Feb 19, 2014 1:44 pm

Thanks for your reply.

Must say, pretty happy to buy Construct 2. Someone or the other is always there to help when m stuck. The tutorial section is also awesome.
B
5
S
1
Posts: 16
Reputation: 408

Post » Thu Feb 20, 2014 7:10 am

M still not able to get it done, can any1 please link me to a tutorial or show some example??
B
5
S
1
Posts: 16
Reputation: 408

Post » Thu Feb 20, 2014 7:16 am

If you describe how you have your slopes set up someone can help, but the solution will depend on that. E.g. off the top of my head, if you are careful to set up all your slopes the same way by taking a horizontal rectangle and rotating it clockwise, then you would simply need to check if the horse overlaps that rectangle and rotated it by the same amount. But if you're doing something else that solution won't work.
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Thu Feb 20, 2014 7:39 am

Try this, it's fairly general so it should work:

Assuming you're using the platform behavior, put every single object that could be a platform in a family called Platforms

Code: Select all
Every Tick --> Set Player Angle to 0
      Player is Overlapping Platforms at X=0, Y= 5
      Platforms Pick Nearest, Player.X, Player.Y   --> Set Player Angle to Platforms.Angle


You need to make sure that you don't rotate platforms more than 90 degrees or else bad things will happen
Last edited by Juryiel on Thu Feb 20, 2014 7:45 am, edited 2 times in total.
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Thu Feb 20, 2014 7:41 am

I made an example for this on the forum not too long ago.
I will have to search the forum to find it.

there's an old example in the arcade, which I adjusted to recognizing the slope angle as explained in the above posts.
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Feb 20, 2014 7:48 am

B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Feb 20, 2014 11:14 am

Thank you all for your help :) Really appreciate your efforts..
B
5
S
1
Posts: 16
Reputation: 408


Return to How do I....?

Who is online

Users browsing this forum: Voytek and 7 guests