[SOLVED] How do I move my crosshair along with the player?

Just started using Construct 2? Post your questions here

Post » Tue Feb 24, 2015 12:19 pm

Hello,

I am making a top-down shooter, played with a gamepad. I currently move with the left stick and move the crosshair with the right stick.

What I want to do now is to move the crosshair with the player when I don't move the right stick. It's a common feature in that kind of game. You can see what I mean in this Hotline Miami for PS Vita video : https://www.youtube.com/watch?v=EW_TeMuAKiU

How can I do that? Is it possible to get the variation of the player's position instead of its position?

I can't upload a capx right now as I'm at work but I can do it tonight if that helps.

Thanks !
Last edited by Flodcp on Thu Feb 26, 2015 2:24 pm, edited 1 time in total.
B
6
S
2
G
1
Posts: 34
Reputation: 595

Post » Tue Feb 24, 2015 12:29 pm

all you you is add crosshair with the right stick in with player movements
B
218
S
30
G
14
Posts: 1,889
Reputation: 37,583

Post » Tue Feb 24, 2015 12:31 pm

Yes, add the player movement to the crosshair so it can move along with the player. That's basically what I'm asking: how to do it. :p
B
6
S
2
G
1
Posts: 34
Reputation: 595

Post » Tue Feb 24, 2015 2:45 pm

Flodcp try this remember there are many ways you could do it. This is simple
You do not have the required permissions to view the files attached to this post.
B
218
S
30
G
14
Posts: 1,889
Reputation: 37,583

Post » Wed Feb 25, 2015 11:10 am

Thanks for your help, unfortunately it doesn't work for me.

I can get if the right stick is moving or not (I tested with a boolean and it works).

I write that when the right stick is moving, then the crosshair position is the right stick one (it works).
I then create another event where I write that when it is not moving, it should be pinned to the player. And it doesn't work.

I will upload my capx this evening.
B
6
S
2
G
1
Posts: 34
Reputation: 595

Post » Wed Feb 25, 2015 11:36 am

As you wish we will look at it and see if we can help
B
218
S
30
G
14
Posts: 1,889
Reputation: 37,583

Post » Wed Feb 25, 2015 5:54 pm

I joined the capx to this message.

The disabled "move to position(200,200)" works, that's why I don't understand why the pin doesn't.

Thanks again for your help.
You do not have the required permissions to view the files attached to this post.
B
6
S
2
G
1
Posts: 34
Reputation: 595

Post » Thu Feb 26, 2015 11:41 am

Add two instance variables to your crosshair : offsetXPlayer1 and offsetYPlayer1 which will both be what you call the "variation".
Add a start of layout event in which you set the offset for each axis.
When the right stick is moving, modify the offset accordingly too.
When the right stick is not moving, position the crosshair to be at the position of the player + the offset.
You do not have the required permissions to view the files attached to this post.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
258
S
90
G
48
Posts: 7,083
Reputation: 62,882

Post » Thu Feb 26, 2015 2:23 pm

Thanks a lot Kyatric! Your solution worked perfectly.

Love this helpful community. :)
B
6
S
2
G
1
Posts: 34
Reputation: 595


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests