Rotating towards angle doesn't seem to work correctly

Here’s The Deal:

I’m trying to make a platformer object rotate to an angle that matches that of the slope it’s on, 0 degrees while on flat ground, 22.5 degrees on a gentle slope, 45 degrees on a steep slope

Expectation:

The object gradually rotates to the specified angle.

Reality:

The object rotates towards the specified angle for a single frame and only changes angles at all if the object was at an angle of 0 degrees as of meeting the conditions.

So if the object is straight and then moves onto a slope, it will turn part-way toward the angle on the slope, but not all the way. If the object is at 22.5 degrees due to going on a gentle slope and then moves onto a steep slope, the object’s angle won’t change at all. What gives?

Here’s The Code I’m using:

Trigger once means do it only once so you are rotating it only once

YOu should add to angle or subtract

Using clamp

clamp(my value , minimal value , max value)

For example
I have HP variable i want to add to it when player is in collision with healing herb but i don’t want it to exceed max HP which is 150
So i can

Player is in collision with healing herb
Change HP variable SET TO clamp(HP + 200 , 0 , 150)

I am adding 200 to HP var but it will not go higher than 150
In this case
Change HP variable SET TO clamp(HP + 17 , 0 , 150)
I add 17 to HP variable and it will also not go no matter than 150
So i don’t need to worry i am adding too much to it cause it will not exceed max HP

Same with subtracting
Imagine i have object group with my enemies
Each enemy have different Damage variable
So doing it easy would be
Player is in collision with Enemies

Change HP variable SET TO clamp(HP - Enemies.Damage , 0 , 150)

Now i do not need to care does vampire Damage var is 40
Or Zombie Damage var is 999999
NO MATER which monster from Enemies group will touch player
It will not reduce HP variable to less than 0
No matter how much HP i had

Now apply same logic to angles

Okay, I tried this, and it’s still only moving toward the angle for a frame, thus making much less steep angles than it should.

Zero said SET TO ,you’re using ADD,
which just means add 2 to angle…
if it does work just for a frame problem should be in the conditions…
prolly bcs after reach 45 or 22.5 conditions are false

1 Like

Seems to have the same problem.

things to check:

1)try with clamp(Object.Angle() + 2, 0, 22.5)…as already suggested

2)is collision with hill permanent ?if not the event works for just a frame

3)for animation “hill=23/45” and flipping …same as point 2

1 Like

Okay, so by changing the collision condition to a distance condition, I was able to get it to rotate for more than 1 frame, so the problem was likely some janky edge case where a slight rotation of the collision mask was preventing the game from registering a collision despite the object still moving along the hill.