How do I make a twinstick Crosshair?

0 favourites
  • 3 posts
From the Asset Store
Make your own spaceship game with this fully customizable set.
  • Hi guys,

    I am making a twin-stick shooter using my gamepad. The left analog stick is set up to make the player move on the layout and right you steer a crosshair to aim for the enemy.

    The layout is bigger than the screen view so the player has a 'scroll to' behavior.

    The ting is that I want the crosshair to be fixed to the screen (like a mouse pointer) so I put the crosshair on the GUI layer (that does not have parallax assigned.)

    The problem is when I want to spawn a bullet (player spawn another object) and set the bullet angle to the crosshair position x and y, the aim is pretty way off. I guess that having the player and crosshair on different layers with different parallax properties that makes the problem.

    How do I get around this problem? Thanks!

  • You can convert coordinates between layers using these monstrous expressions:

    CanvasToLayerX("Player", LayerToCanvasX("HUD", x, y), LayerToCanvasY("HUD", x, y))

    CanvasToLayerY("Player", LayerToCanvasX("HUD", x, y), LayerToCanvasY("HUD", x, y))

    These will convert HUD layer coordinates (x,y) to Player layer coordinates.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you so very much dop2000!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)