How do I make the cannon only rotate 180 degrees

2021-12-21_10-43-37

How do I make the cannon only rotate 180 degrees
and not 360

And smoke cannon ??

Example

many thanks (^_^)

You need the angle condition, but you also need some key pressed condition, or mouse X position condition.
For smoke, use the particle emitter object.

For limiting the angle you can use the clamp expression.

@Gruk @Drona

Code not set
It still rotates 360??

Hi, what do you mean? You have no code in your event sheet?

Hi, first of all you did not use the clamp function as I suggested in my first post that limits the angle of your canon. Second it seems that your canon sprite is not aligned properly. If it should rotate as expected it needs to be aligned horizontally - not vertically - by default when you import it in the engine. 0° is located to right or east. You can read about that here: Basic game making concepts: What you need to know to start with GDevelop [GDevelop wiki]

@Gruk @Drona

Unfortunately
I didn’t succeed
Example file
please help :smiling_face_with_tear:

https://drive.google.com/file/d/1uIvfsm177LajU61nOYP83q4vWBxTY1UE/view?usp=sharing

Not sure if you have an answer to this yet. Here’s a quickly cobbled together solution :

These events result in :

limitedRotation

1 Like

@MrMen @Drona @Gruk
I’m still trying :smiling_face_with_tear:

And what happened with my solution, which answered your request?

1 Like

MrMen’s solution works when you want to change the angle of the canon by pressing keys. What I suggested works when the canon follows the mouse. Which one do you need and what do your events look like now? (I - and probably MrMen and Gruk as well - prefer if you just post a screenshot of your events here instead of providing a link to the project).

2 Likes