[FIXED] How do I make object follow Mouse on certain degree

From the Asset Store
112 High-Quality destruction sounds for videogames
  • Hello,

    I'm stuck at figuring out how to make an object (e.g. a head) follow the mouse, but only between certain angles.

    Added a pic to better picture it (huehue)

    P.S. The layout is rotating, so the angle (of the player) is changing, but I'll figure that out somehow... just the basics first...

    Has anybody an Idea how to do it?

  • I guess you could use the system is between angles condition..

    I would use the body angle to compare with, in this case..

    so that would be something like this:

    angle(head.x,head.y,mouse.x,mouse.y is between body.angle-45 ; body.angle+45

    head rotate 1 degrees towards angle(head.x,head.y,mouse.x,mouse.y


    head rotate 1 degrees towards body.angle

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Another way would work with the clamp expression

    System every tick

    head set angle :clamp(angle(head.x,head.y,mouse.x,mouse.y), body.angle-45, body.angle+45)

    Problems that could arise are that sometimes the expression(s) return negative angles..

    If this is the case and it messes up the actions, adding 360 when values are negative should solve this..

  • I found this on my .capx downloads folder <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> ... maybe will help you ... its what LittleStain explained

    https://www.dropbox.com/s/nkwa654q4s3hs ... .capx?dl=0

  • Thank you guys so much! Every time I tried it the head would flicker back. This is so helpfull!

    I'm gonna try all the examples, so see which fits best my needs.

    But just omg, I can't belive how happy I am right now

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