Limit rotation

Get help using Construct 2

Post » Sat May 11, 2013 4:19 pm

Hey, I have a cannon like object with "set angle toward (mouse.x,mouse.y)
on every tick. (thats the entire capx)

I need this cannon to stop rotating and remain fixed if the mouse causes the angle to be above say 260 or below 45.

Also it will need need to work when the cannon faces the other direction.
I just dont want it to shoot more or less strait up and down

Thanks and I'm new

P.s. I tried turret range behavior but that is for detecting targetsfarnsu2013-05-11 18:58:48
B
8
S
3
G
2
Posts: 20
Reputation: 1,759

Post » Mon May 13, 2013 2:21 pm

Well, I thought of a way but its really stupid make the cannon invisible when it reaches a certain angle and then spawn a static one in its place, but its lame I was hoping 2 do it the math way
B
8
S
3
G
2
Posts: 20
Reputation: 1,759

Post » Mon May 13, 2013 2:29 pm

+Every Tick
-> set angle toward
-> if angle > max angle
--> set angle to max angle
-> if angle < lowest angle
--> set angle to lowest angle

you could also set the if to the every tick(this would save unecesarry..) but when you will be every time a bit above or under your max.
B
15
S
6
G
6
Posts: 512
Reputation: 5,550

Post » Mon May 13, 2013 2:37 pm

Ok. im trying that now
B
8
S
3
G
2
Posts: 20
Reputation: 1,759

Post » Mon May 13, 2013 4:00 pm

Im having trouble with this part:
-> if angle > max angle

Is this a 2nd condition after: -> set angle toward mouse x/y
Do i need a variable to get the angle of the cannon?
I cant find a condition that just retrieves the current angle?
B
8
S
3
G
2
Posts: 20
Reputation: 1,759

Post » Tue May 14, 2013 9:28 am

Nah,

Add condition -> system
+ Compare Two Values
First value = max angle
Comparison = <
Second Value = yourObject.angle

Thats it, nothing more. .angle = get the current angle of an object

B
15
S
6
G
6
Posts: 512
Reputation: 5,550

Post » Mon Feb 29, 2016 6:48 pm

farnsu wrote:Hey, I have a cannon like object with "set angle toward (mouse.x,mouse.y)
on every tick. (thats the entire capx)

I need this cannon to stop rotating and remain fixed if the mouse causes the angle to be above say 260 or below 45.

Also it will need need to work when the cannon faces the other direction.
I just dont want it to shoot more or less strait up and down

Thanks and I'm new

P.s. I tried turret range behavior but that is for detecting targetsfarnsu2013-05-11 18:58:48



hi farnsu did you manage to fix this i been trying to do the same for more than two weeks, is it posible you share a capx if you fixed it thanks a lot
B
26
S
12
G
11
Posts: 36
Reputation: 7,579


Return to How do I....?

Who is online

Users browsing this forum: gregorysforster, WhosWho and 17 guests