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

Get help using Construct 2

Post » Thu Nov 19, 2015 4:17 pm

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

Image

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?
Last edited by Icon3x on Fri Nov 20, 2015 9:04 pm, edited 1 time in total.
B
5
S
1
Posts: 10
Reputation: 572

Post » Thu Nov 19, 2015 4:36 pm

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

else
> head rotate 1 degrees towards body.angle
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Nov 19, 2015 4:45 pm

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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Nov 19, 2015 10:04 pm

I found this on my .capx downloads folder :) ... maybe will help you ... its what LittleStain explained
https://www.dropbox.com/s/nkwa654q4s3hs ... .capx?dl=0
B
32
S
9
G
9
Posts: 198
Reputation: 6,712

Post » Fri Nov 20, 2015 9:27 am

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 :D
B
5
S
1
Posts: 10
Reputation: 572


Return to How do I....?

Who is online

Users browsing this forum: Ajbael, the_Shit_hawk, zenox98 and 6 guests