How do I rotate a pinned sprite with constraints

Get help using Construct 2

Post » Mon Apr 06, 2015 10:14 am

Hi,

Im trying to create a player unit that has an upper and lower body, upper being the torso and lower the legs so i can set it upso that the legs canbe controlled separately as well as the upper body. Now it was a cinch to get it to work like a tank so that the upper body would rotate a full 360 degrees where the mouse points and moving the lower part with arrow keys. But id like it to have a constraint such as a normal body that it cannot rotate more than say 90 degrees to either side from where the lower half is pointing at. How would i get such a thing done?
B
7
S
1
Posts: 93
Reputation: 632

Post » Mon Apr 06, 2015 10:21 am

Using the clamp expression you could probably get this done.
It would look something like this:

Upper body set angle - clamp(angle(upperbody.x, upperbody.y, mouse.x, mouse.y), lowerbody.angle-90, lowerbody.angle+90)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Post » Tue Apr 07, 2015 6:26 am

It actually seems to work in the starting direction allright, but as soon as you walk a different way, the upper body stops functioning right.Why is this? Im guessing the program gets confused on the angle of the player since the staring angle is 0, but when you start walking left. it changes to 180, so the upper body cant work on the mentioned +/- 90 degree angles? Or is it something else.

..why cant i post a file anymore :| ?? would be easier to show the file. Oh well..dropbox will do
Code: Select all
https://dl.dropboxusercontent.com/u/73502848/upperlowerbody/uplow.capx


I suppose it would be worth mentioning that im trying to make an isometric game if i get somewhere with this, so that will propably create its own problems too. im guessing id have to greate a frame to each individual turn degree or am i going this completely the wrong way? Im pushing for an isometric world with an alien swarm type of movement.
B
7
S
1
Posts: 93
Reputation: 632

Post » Sat Apr 11, 2015 7:37 am

I would really appreciate any pointers with this, i can't figure it out even though im pretty sure its something simple.
B
7
S
1
Posts: 93
Reputation: 632

Post » Mon Apr 13, 2015 5:13 am

I was playing with "is between angles" (see: https://www.scirra.com/manual/131/common-conditions ) a while ago - maybe this could give you another starting point ?

https://dl.dropboxusercontent.com/u/143 ... /tank.capx
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
62
S
31
G
39
Posts: 1,194
Reputation: 26,512

Post » Sun May 03, 2015 7:57 pm

Message: Juicy is not yet permitted to post plain text URLS (300 rep required). 2 URLS removed. Why?
RamPackWobble wrote:I was playing with "is between angles" (see: ) a while ago - maybe this could give you another starting point ?


That..actually works quite damn well ! :) The only issue i get now, is that the rate of turn is somewhat slow. I tried increasing the rotation from 1 to 10 which speeds things up, but also increases the jutter you experienced as well. Figured a way to stop this from happening?
B
7
S
1
Posts: 93
Reputation: 632

Post » Wed May 06, 2015 5:02 pm

Tried everything in my very slim book of tricks, but im still fighting to get this done. RamPackWobbles idea works like a charm, but it creates a jutter when the angle exeeds its limit. This can be minimized by lowering the degree amount that the object rotates, but this also slows the momement down. Its so close i can taste it, but still not there, so help..please.
B
7
S
1
Posts: 93
Reputation: 632

Post » Thu May 07, 2015 9:42 pm

I will have another play over the weekend and see if I can improve on it (one idea does come to mind).
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
62
S
31
G
39
Posts: 1,194
Reputation: 26,512

Post » Thu May 07, 2015 10:37 pm

@RamPackWobble

we already got alot further in this thread:

how-do-i-get-this-vibration-ironed-out_t130167

But maybe you could shine your light on it..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Post » Fri May 08, 2015 6:45 am

@LittleStain

Thanks - didn't realise there was another thread. I will download and assimilate...

Once again my light is redundant :)
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
62
S
31
G
39
Posts: 1,194
Reputation: 26,512


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Bobbyneal100, Matthew de, R0J0hound and 5 guests