# How do I rotate an object with different pictures for each.

0 Favourites
• 8 posts
• Hi!

In my previous top down games, the character looks at the crosshair and the image is rotated accordingly

Now i want to have a view with slight angle (imagine starcraft view), so i need to change character picture depending on what direction the character is looking, not only rotate the character sprite

Brute force solution would be to define single picture sprite animations for each rotation and go

If angle is blabla, set animation blabla

one condition for each picture

Is there a more convenient way to do this?

• I don't think there is a better solution other than comparing the angles and changing animations.

System-> Is between angles -> Character.8Direction.MovingAngle between -45 and 45 : Character set animation frame 0

System-> Is between angles -> Character.8Direction.MovingAngle between 45 and 135 : Character set animation frame 1

etc.

• Thanks!

Thats an upgrade, to use the animation frames instead of changing animations

I guess the frames can be the result of a formula, mapping every degree to a frame number

• But if your sprite has animation, changing only the frame wont work.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Right...

any other workarounds?

the interface for multiple animations in one sprite is quite hard-worked.

Could I use numbers as names for animation and change animation via math formula with angle as input?

• Theres no need to set the animation name to numbers, you can use names (strings) and change the animation by the name checking angles.

Just to clarify, you have an isometric game-type, is that it?

In my mind theres no way to achieve this without having animations/drawnings as we're working on a 2d environment.

If you can, wait sometime. Maybe someone has a way.

• Here is the formula to get the angle in 0-360 degrees range:

a=(Player.8Direction.MovingAngle+360)%360

If you want to have just one formula, I guess you can do something like this to get numeric value 0-3 for player direction:

d = (a>315 | a<=45) ? 0 : (a>45 & a<=135) ? 1 : (a>135 & a<=225) ? 2 : 3

Then set animation frame to d.

Or you can name your animations "A0", "A1", "A2", "A3" and set animation to "A" & d

• Thank you dop2000!