Gamepad Right Stick as Crosshair?

0 favourites
  • 5 posts
From the Asset Store
This is a twin stick shooter similar to Enter the gungeon,Nuclear Throne, Helldivers & Soul knight for the mobile device
  • Hello,

        This is my first post on the forum, and I've been looking around and could not find my answer.

        So, I'm creating a side scrolling shooter, and I have the aim currently following the mouse so when I shoot bullets they go to where the mouse is on the screen.

        

        My objective: Create a cross-hair, or mouse, that is controller by the right stick on a Xbox 360 gamepad. I currently only find how to change the angle of other objects toward the mouse. Help is appreciated.

    Thanks :)

  • An easy way to control a sprite with the analog stick of a gamepad would be to add the custom movement behavior to the relevant object.

    Then set its horizontal speed according to the X axis of the right analog stick with the expression "Gamepad(0,2)" and the vertical speed according to the Y axis with "Gamepad(0,3)".

    These expressions return a range from -100 to 100, so you should multiply here with the maximum speed value of your object. Also dont forget delta time "dt"!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • it's just as simple without custom movement,

    crosshair | set x to self.x + Xaxis*speed*dt

    crosshair | set y to self.y + Yaxis*speed*dt

  • it's just as simple without custom movement,

    crosshair | set x to self.x + Xaxis*speed*dt

    crosshair | set y to self.y + Yaxis*speed*dt

    Agreed. I'm merely suggesting custom movement for handier expansion of the movement, since the behavior provides useful expressions, conditions and actions. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • > it's just as simple without custom movement,

    > crosshair | set x to self.x + Xaxis*speed*dt

    > crosshair | set y to self.y + Yaxis*speed*dt

    Agreed. I'm merely suggesting custom movement for handier expansion of the movement, since the behavior provides useful expressions, conditions and actions. <img src="smileys/smiley1.gif" border="0" align="middle" />

    I'll have to try these both out later today, I couldn't figure it out in the time waiting, so I just made the gun rotate with the rightstick and shoot in the direction it was facing. Then, made the crosshair at the gun position and I put an imagepoint about 200 pixels to the right of the gun barrel so it would act as a crosshair basically.

    I just started using this program so I kind of get what you guys said, I'll try my best to figure out what you both told me so I can apply it.

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