Limited angle on a moving object

This forum is currently in read-only mode.
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hello. Ask a petition for my english , because I use online translators.

    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 ?

    clamp(angle(gun.x, gun.y, mousex, mousey), corps.Angle-30, corps.Angle+30)[/code:1ecok5id]
    If you want to show the example: [url=http://dl.dropbox.com/u/1086462/rotation%20is%20limited.cap]http://dl.dropbox.com/u/1086462/rotatio ... imited.cap[/url]
    Thanks...
  • How we can improve this expression ?

    clamp(angle(gun.x, gun.y, mousex, mousey), corps.Angle-30, corps.Angle+30)[/code: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.

    + 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:
    [url=http://www.mediafire.com/file/9zt9y0v1d44vyg4/rotation%20is%20limited2.cap]rotation is limited2.cap[/url]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you very much . You helped me a lot .

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)