How do I rotate a sprite toward another but not from origin?

Get help using Construct 2

Post » Tue Aug 12, 2014 11:37 pm

2014-08-13 00_30_46-Construct 2 beta release r176 (Administrator) - PlanetPlayerAim.capx - Layout 1.png


Hello guys. That's a screenshot from my editor.
The arm is a different sprite from the body. The origin of the arm is on the blue circle.
The player can rotate that red ball around the player. I want the arm to point at the red ball always, but since the arm is pinned to the body, it rotates funny. The hand doesn't exactly point to the red ball.

How can I both lock the arm to the body at the shoulder level AND make it rotate in a way the hand follows the red ball?
You do not have the required permissions to view the files attached to this post.
B
8
S
2
Posts: 39
Reputation: 1,492

Post » Wed Aug 13, 2014 8:10 am

I am guessing your arm is in the wrong orientation in the editor. If you edit your arm sprite it should look like the shoulder is at the left and the hand at the right. The place the image point at the shoulder. Its should work just fine then.
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Wed Aug 13, 2014 10:01 am

Thanks for the help spongehammer.
It really doesn't matter what way I set in on the editor, when I play the game it will always start in a specific position.
I don't really know what the problem is, could you or anybody take a look at my project?
You can move the red circle with buttons Q and E or the left stick if you have a gamepad
https://www.dropbox.com/s/3o8k47rwuugfd ... mancy.capx
B
8
S
2
Posts: 39
Reputation: 1,492

Post » Wed Aug 13, 2014 10:15 am

Your arm sprite needs to be horitontal in the editior. If you rotate it 90 degrees so the hand is on the right It will work. In actual fact the arm image needs editing externaly so its horizontal not at an angle. Also you need to alter your aim calculations. I am not sure from what i see exactly where the red aim point is supposed to be.
It seems a little overcomplicated for what you are trying to achieve.
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Wed Aug 13, 2014 10:25 am

See attached capx. Either drag the girl around or the red ball.
You do not have the required permissions to view the files attached to this post.
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Wed Aug 13, 2014 10:33 am

Didn't seem to make much progress by editing the image and rotate it as you suggested.
I'm not sure what's the problem with the aim calculations. Could you elaborate on this? It's supposed to move 180 degrees around the player, like a semicircle
B
8
S
2
Posts: 39
Reputation: 1,492

Post » Wed Aug 13, 2014 10:37 am

Here is another option. Use the Q & E keys to move the aim.
You do not have the required permissions to view the files attached to this post.
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Wed Aug 13, 2014 10:53 am

The pointing there works as expected :) Unfortunately in my game you move the character around the planet (A and D), and you don't want him to be able to move the aim towards his own planet, that's why full rotation is limited.
B
8
S
2
Posts: 39
Reputation: 1,492

Post » Wed Aug 13, 2014 11:12 am

Well limiting rotation using my method is simply a check to see if it is between angles. That way you can set it to rotate to and from any angle. :) Plus my maths isnt great so i always look for a simpler way :)
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Wed Aug 13, 2014 7:18 pm

Ok! I implemented your way in my prototype and at least I got the "pointing" working properly now. Thank you very much :D
Still having problems limiting the angle in away the Aim doesn't touch the planet, because here:
2014-08-13 20_15_16-Sonomancy (Construct 2 preview).png

The angle is not the same that when she is down here:
2014-08-13 20_15_39-Sonomancy (Construct 2 preview).png


This needs some math creativity. How can I clamp the rotation of the red circle so no matter the position the player is around the planet, the circle never can rotate over the planet?
You do not have the required permissions to view the files attached to this post.
B
8
S
2
Posts: 39
Reputation: 1,492

Next

Return to How do I....?

Who is online

Users browsing this forum: Laura_D and 25 guests