how to Make object following mouse,but the angle stay still?

Get help using Construct 2

Post » Mon Jan 23, 2017 2:38 pm

|how to make an object move following mouse, but the angle stay still ?| or make an object move following the position of other object without changing the angle ?
B
8
S
4
Posts: 46
Reputation: 858

Post » Mon Jan 23, 2017 2:53 pm

You need to store the position of the object in an instance variable (X and Y) and change the angle of the object to the angle between the stored position and the position of the mouse every tick. If that's what you want.
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Tue Jan 24, 2017 3:12 pm

so... every tick, set angle to instance var ? i cant understand it..
B
8
S
4
Posts: 46
Reputation: 858

Post » Tue Jan 24, 2017 3:12 pm

and it wont work
B
8
S
4
Posts: 46
Reputation: 858

Post » Tue Jan 24, 2017 3:41 pm

No, you need to set the angle between the coordinates from the instance variables and the coordinates of the cursor. That's the angle you need
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Wed Jan 25, 2017 2:32 pm

i want it to follow the mouse, not going straight to the position of the mouse.. my english is a bit suck.. maybe you can explain in a more simple languange .. haha
B
8
S
4
Posts: 46
Reputation: 858

Post » Wed Jan 25, 2017 7:36 pm

Message: RobertMKD can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Ah, sorry, I missed the part where you say that you don't want it to change the angle. You probably want to control the object using your mouse arrow right?

Well, in that case, you should take a look in this C2 template 'Space Blaster' which you can find at File>New>Space Blaster:

http://prntscr.com/e0amyz

In this example, the spacecraft moves only when you are touching the screen, but in your case you should change the touch conditions with the ones used for mouse. Also don't forget to add the mouse plugin to the project.
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Thu Jan 26, 2017 3:35 pm

/
Last edited by AnotherUser on Thu Jan 26, 2017 4:48 pm, edited 1 time in total.
B
8
S
4
Posts: 46
Reputation: 858

Post » Thu Jan 26, 2017 3:48 pm

Maybe you can create 2 sprites.

SKIN_SPRITE and POSITION_SPRITE.

Use POSITION_SPRITE for all your movements. Set its angle to mouse, set it to invisible if you want.

Set SKIN_SPRITE position to POSITION_SPRITE.
SKIN_SPRITE will then serve as your character.
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 832
Reputation: 20,807

Post » Thu Jan 26, 2017 4:28 pm

genius, thx so much C:
B
8
S
4
Posts: 46
Reputation: 858


Return to How do I....?

Who is online

Users browsing this forum: kriand and 2 guests