Limited angle on a moving object

For questions about using Classic.

Post » Thu Mar 17, 2011 8:03 am

Hello. Ask a petition for my english , because I use online translators. :oops:
The essence of the problem: can not create an object with a limited angle of rotation of the object on the mobile.
picture for understanding:



How we can improve this expression ?
[code:1ecok5id]clamp(angle(gun.x, gun.y, mousex, mousey), corps.Angle-30, corps.Angle+30)[/code:1ecok5id]
If you want to show the example: http://dl.dropbox.com/u/1086462/rotatio ... imited.cap
Thanks...
B
1
G
1
Posts: 2
Reputation: 429

Post » Fri Mar 18, 2011 5:57 am

[quote="oldchivas":28xqihdm]
How we can improve this expression ?
[code:28xqihdm]clamp(angle(gun.x, gun.y, mousex, mousey), corps.Angle-30, corps.Angle+30)[/code:28xqihdm]
[/quote:28xqihdm]
Avoiding any own math like modulo etc, you have to split it to two subevents and use the 'AngleDiff' expression and the 'Angle is clockwise of' condition.

[code:28xqihdm]+ System: Always (every tick)
-> gun: Set position to object corps (image point 0)
++ System: Angle angle(gun.x, gun.y, mousex, mousey) is Clockwise from corps.Angle
-> gun: Set angle to clamp(AngleDiff(angle(gun.x, gun.y, mousex, mousey) , corps.Angle), 0, 30) + corps.Angle
++ System: Else
-> gun: Set angle to clamp(AngleDiff(angle(gun.x, gun.y, mousex, mousey) , corps.Angle) * -1, -30, 0) + corps.Angle[/code:28xqihdm]

Download:
rotation is limited2.cap
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Fri Mar 18, 2011 3:56 pm

Thank you very much . You helped me a lot .
B
1
G
1
Posts: 2
Reputation: 429


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests