How do I rotate objects but keep them between 2 angles

Get help using Construct 2

Post » Thu Sep 24, 2015 7:41 pm

Hello
I am working on a side scrolling shooter and i would like the spine, torso, neck and head to all rotate towards the mouse.
Easy enough right but, i want each obeject to have it own rotation boundrys so the player doesn't brake his back and do wierd stuff if you catch my drift.
i cannot figure this out, so i tried the easy way and make alot of sprites connected them to the players boundry box so the mouse has to be within a certain sprite for the body part to rotate, but it isnt the best, im sure there is and easier more officiant way.
here is the construct file with love and hope :0.

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

thankyou :).
B
8
S
2
Posts: 51
Reputation: 1,235

Post » Fri Sep 25, 2015 6:51 am

For each of the sprite (spine, torso, neck) etc, have an event that checks its current angle in relation to the body part sprite that its connected to.

It's a case of if, else logic.

ie.

If Neck.Angle > Spine.Angle + 45 => Set Neck.Angle to Spine.Angle + 45.

Thus, the Neck can never rotate more than 45 degrees in relation to the spine. It will snap to 45 degrees relative to the spine whenever you go beyond. Do to the same for the Spine.Angle -45 or whichever way in reverse and it will work.

Hope that helps!
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,614

Post » Sun Sep 27, 2015 7:37 pm

Sorry i have been away for a while.
Thankyou very much @silverforce it worked perfectly :).
I have one more problem though, i have pinned all the body parts together but the forearm likes to lag behind, even though nothing else does and they are all set up exactly the same.
i dunno why :/.
here is the file if you need to have a look thankyou :).

https://www.dropbox.com/s/1uh1isbe45syi ... .capx?dl=0
B
8
S
2
Posts: 51
Reputation: 1,235

Post » Sun Sep 27, 2015 8:44 pm

I definitely think its has something to do with layer parallax, but I couldn't figure out what. Also there is a better way to do camera let me know if you want to know
B
14
S
2
Posts: 24
Reputation: 843

Post » Sun Sep 27, 2015 9:59 pm

yeah sure all tips are welcome buddy :).
B
8
S
2
Posts: 51
Reputation: 1,235


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Casimir, tarek2, Yahoo [Bot] and 11 guests