360 Aiming in Top-Down Shooter (Hotline Miami clone)

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Easiest is probably using the built-in physics race-car movement,
    will handle angles for you,
    while shooting can just be:

    on fire 1
    >>> shoot "bullet" at speed xxx - use direction of "character"


    Best looking, precise and complete solution would probably involve using some trigonometry.

    a selection of my Fusion examples can be found Please login to see this link.

  • I created a crosshair and choosed that it is mouse controlled. Now I don't know how to do that character face to the mouse controlled crosshair. So character should walk if keyboard pressed and rotate when I move mouse and crosshair.

  • To rotate the player and let him face the mouse (or crosshair) you have two choices:

    builtin way:
    set angle to OAngle("player", "xmouse", "ymouse")

    best way:
    set angle to ATan2(Y( "player" ) - ymouse, xmouse - X( "player" ) )

    a selection of my Fusion examples can be found Please login to see this link.

  • This second choice is exactly what I mean, thank you very much and it is of course working like a charm. But how it is work? Could you explain me how it works?

    Now I saw that both are working, I made a mistake in the first.

    Edited once, last by muskalator: Now I saw that both are working, I made a mistake in the first. (August 23, 2015 at 5:19 PM).

  • In the first one I included some extra "quotes" for xmouse and ymouse, maybe this led to your troubles, sorry!

    The second one will show its additional potential on further distances,
    since it will give you floating point precision,
    while the OAngle function only returns integer values.

    But they work quite the same on smaller distances.

    The Atan2 notation calls the "arctangent" mathematic function,
    an inverse trigonometric function that will give you the angle between a horizontal X axis and the vector between two points,
    here we have specified the two points being your player's X,Y and the mouse X,Y position.

    a selection of my Fusion examples can be found Please login to see this link.

  • Thanks again :) Now I've got another problem because when I'm shooting bullets they are accurate at close range. But longer distance shoots aren't accurate at all. What is the easiest way to improve it in CF2.5?

  • If you're using set angle to OAngle("Player", xmouse, ymouse)
    The result can be 33

    With set angle to ATan2(Y( "Player" ) - ymouse, xmouse - X( "Player" ) )
    The result can be 33.7299

    The float values bring accuracy to the table. So for perfect accuracy use the second method.

    - BartekB

    Join the Click Converse Discord! - Please login to see this link.

  • Assuming you're using the Atan2 method,
    you probably have to setup a precise method for "directing" the shoot
    (the builtin "shoot in direction of..." just aims in limited range of directions)

    You may check this bullet example (second post):
    Please login to see this link.
    main focus here was on collision, but it also embeds correct aiming at crosshair like you need

    check the "fastloop bullet" group!

    a selection of my Fusion examples can be found Please login to see this link.

  • I think you will notice a bigger difference in results the longer the distance of the bullet travels. So doing some target practice testing up close you can't see a difference, but taking long shots you could.

    Check out my Game on Itch.io
    Please login to see this link.

  • I did it in a different way. I used bouncing ball movement with "Bullet" checked in movement properties and it works like a charm, I think that it is a best method for this case. Thanks guys for ideas.

  • The physics movement is a great idea! :) To step in late here: I made a Please login to see this link. the other day using 360-degree movement/rotations in case you're curious about that. It uses floats (decimal points) so that the projectiles always move precisely toward the target regardless of distance.

  • Very cool example Snail!

    This other example I was referring was targeting (and colliding) with floating precision too >:)
    Please login to see this link.
    (maybe lower "speed" value of the bullet object to see better..)

    but I guess muskalator was happier with an equally-good-looking-but-easier-to-handle solution XD

    a selection of my Fusion examples can be found Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!