Radial Aiming Problems (Position & Angle)

0 favourites
  • 5 posts
  • I'm trying to implement a simple radial aiming mechanic using gamepad controls. So far, I have this working, where the position of the aiming sprite is set to the player's centre, as if the character was holding/aiming the weapon by their side. However, my intention is to have the aiming sprite offset so that can orbit the player by a set distance (i.e. like a 360 degree floating turret).

    I thought I could achieve this by messing around with ImagePoints, but this doesn't seem to work as intended (the angle of the sprite does not line up with the position of the analogue stick). Can anyone suggest a particular approach here? I feel like it should be relatively simple, but I'm missing something obvious.

    A secondary issue I have is that the aim angle springs back to the original position, understandably, as the analogue stick is disengaged. How would I be able to leave the position of the aiming sprite in the last position that the player aimed in? Would I need to report the last set position to a variable and then set the angle to that when the stick isn't in use, or again, is there a simpler method that I'm missing?

    Thanks for any help you can provide!

  • I used set position to center and move at angle every tick. Condition is that the analog stick is not in deadzone.

    Normally you have an else after this to reset to center, but if you don't then the reticle will remain where it is.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Brilliant, thanks for your help; do you happen to have a screengrab of the events or an example capx to hand?

  • I scanned through my c3 library and didn't find an example for it, I may have made it in C2.

    Check out howtoconstructdemos.com/category/virtual-joystick , there are a few implementations there. See if you can adapt the way the virtual joystick is displayed to your sprite, it should be similar.

  • Just an update for anyone reading this thread in the future; I managed to get all of this working by changing the way that the weapon is attached to the player in the first place, and it was really simple.

    First, I changed the Origin of the turret to 64 pixels behind it, and pin this to the centre of the player at the start of the layout. Next, I used a condition to check that if the axis of the right analogue stick is anything other than 0, put it into a global variable and then set the angle of the turret to this. This is essentially how the demo twin-stick shooter handles it.

    Simple yet functional!

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