Mouse controlled AIMing point.

0 favourites
  • 11 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Hello !

    i'm working on a top down shooter type "hotline miami"

    the character is moved by the arrows,

    and he can aim and shoot with the mouse.

    actually i use this :

    bullet > set angle toward (mouse.x, mouse.y)

    it works, BUT .

    when the mouse is really near my character, things become buggy.

    and when the mouse is very far from the charachter , you have a long way back if you want to turn around.

    what i would like to do :

    the aiming point is controled by the mouse, but its not the mouse.

    the aiming point follow the direction of the mouse , but is bounded in a circle which the center is the character.

    the aiming point is always on this circle at 300 pixel (for example) of the character.     never closer and never far away .

    so the mouvement you need to do to have a specific reaction will always be the same, despite the real position of the mouse.

    i tried to be clear, dont know if you can understand what i mean.

    if someone can help, it would be apprecied !

    thanks !

  • You could try giving your character Turret behavior, and have its target be a sprite that's restricted within the circle you want but mouse-controlled.. That will have him/her rotate at a predefined rate towards the mouse, no matter where the mouse is or how fast it's going.

    The last thing I'm not sure how to do, good luck!

  • Look at the Diablo style movement example. It could probably easily be modified for shooting.

    Capx: dl.dropbox.com/u/23551572/C2/diabloLikeMov.capx

  • dont set angle of the bullet, just set the top down shooter direction every tick to mouse x mouse y, the bullet will shot towards the direction of the mouse.

  • Ice : i cant because the bullet is spawned by the weapon, which is not at the center of the character sprite, so if i do that the bullet dont reach the target , there is the same offset a the arriving that there is a the departure.

    ChrisAlgoo : i didnt experiment the turret behavior yet. i'm going to test that. but i dont think it will do

    Wigriff : i checking that right now !

    thanks all.

  • no i dont think i can use this wigriff.   

    maybe i wasnt enough clear.

    basically i think the mouse should only pilot the aiming

    imagine a circle of 200 pixel with the character in the center.

    if i go 200 pixel left, my aiming is at the maximum left,

    i go 200 pixel right the aiming go to the maximum right,

    then i go 200 pixel left, then again 800 pixel left,

    the mouse is now 1000 pixel away from the center, but if i move 200 pixel right, the aiming still go to maximum right.

    so even if my character is in the center and the mouse in the upper left corner, i can piloy my character the same way as if the mouse was in the center.

    and when my mouse is between the character and the circle, the aiming point stay always on the ring.

    am i more clear ?

    in fact i think we need to forgot the position of the mouse.

    what is important is in which direction the mouse is moving.

  • Example capx using the pin behavior.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Kyatric !

    wonderful ! that will do perfectly.

    the problem when the mouse is too close of the hero is now solved !

    that was the main thing so : thank you very much !

  • Kyatric

    in fact, that was interesting but not definetly good.

    ...

    im checking the math formula and expression all deay, but still dont know how to do it.

    basically : center of "player" is point "A"   ans mouse is point "B"

    i need to obtain the line between A and B and display my "aim" on this line, at 150 pixel distance from point A .

    know how to do that ?

  • no no. my mistake. i will have the same problem with that when my mouse will be between the aim and the player.

    need to think about it again .

  • Make a image point on the player sprite at that position called bulletspawn and spawn from there?

    Or you can spawn from the gun and set the bullet angle of motion to "player.angle".

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