How do I make my cursor pin to my player ?

0 favourites
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • we.tl/t-y1C25TJaFW : the project

    I would like to make my cursor following my player. When i am moving my character. I want that my cursor follow the player. in the same direction?

    thanks

  • LeKinkss

    Do you mean mouse cursor following the character? If yes, how would that work out play-ability wise ?

    Or you mean a cursor sprite that follows the character?

  • LeKinkss

    Do you mean mouse cursor following the character? If yes, how would that work out play-ability wise ?

    Or you mean a cursor sprite that follows the character?

    So, when you are moving the mouse, the aim of your character follow the mouse/cursor. But i want that when the player is not moving the mouse, the aim stay in the same direction as previously. And not follow the mouse.

  • LeKinkss

    Do you mean mouse cursor following the character? If yes, how would that work out play-ability wise ?

    Or you mean a cursor sprite that follows the character?

    Like in this game : store.steampowered.com/app/1205170/Super_Magbot

  • Okay. That added some clarity, and character is controlled by keyboard ?

  • Turret angle should be set where mouse cursor is at (or an invisible sprite following the mouse cursor that defines the angle point).

  • Okay. That added some clarity, and character is controlled by keyboard ?

    yes, A and D for left and right

  • To determine if the mouse is moving you need to save the mouse's coordinates to variables every frame and then compare them to the current coordinates:

    Use these events:

  • To determine if the mouse is moving you need to save the mouse's coordinates to variables every frame and then compare them to the current coordinates:

    Use these events:

    Turret is the aim of the mouse ? what's it in your code ?

    its not working with my aim cursor which follows the mouse

    Do you donwload my project ? there is events for the mouse before, maybe its not working because of this

    What is your turret in your code ? the gun of my character ? he doesnt have one

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Turn off all of your other events for setting the angles of you lazer and projectileimpulsion.

    Add the events and variables in from my post.

    Replace the "turret" in event #3 in my events with "lazer" from yours. (event #13)

    Now edit the event Projectileimpulsion - set angle to AngleDiffViseurPerso and instead set angle to lazer.angle. (event #18)

    Now the angle of the turret and any spawned projectiles will be set towards the mouse position if the mouse is moving. If the mouse is not moving they will be set to the last angle.

  • Turn off all of your other events for setting the angles of you lazer and projectileimpulsion.

    Add the events and variables in from my post.

    Replace the "turret" in event #3 in my events with "lazer" from yours. (event #13)

    Now edit the event Projectileimpulsion - set angle to AngleDiffViseurPerso and instead set angle to lazer.angle. (event #18)

    Now the angle of the turret and any spawned projectiles will be set towards the mouse position if the mouse is moving. If the mouse is not moving they will be set to the last angle.

    it didnt work... :'( i am so bad

    the lazer follows and stop. that is working. But the game didnt keep the last angle, and why i click, the lazer go to the position of the mouse and spawn the projectile.

    can you help me please ? : we.tl/t-DTYNfqiC26

    i want to work it so bad.. but with my code, it didnt work.

  • Have a look at this. There were issues with screen shake causing movement on your mouse position so to get around this I used absolutemouse positions instead.

    1drv.ms/u/s!AkmrWgxeuxlKhIgsXevC8baOBxWWLw

  • Thanks !!!

    Last thing, now, my mouse cursos is getting stucked on edge of the screen. My computer screen when on full screen. What can i do to not stopped the mouse ?

  • Your "DistanceJoueurExplosion" is calculated every tick, once all the explosions happened, in event 26.

    Simply take the action that make that calculation and add it to event 22 before the "ProjectileImpulsion" destroy action and your code will work as intended.

    Thanks !!!

    Last thing, now, my mouse cursos is getting stucked on edge of the screen. My computer screen when on full screen. What can i do to not stopped the mouse ?

    What do you exactly want to do ?

    "What can i do to not stopped the mouse ?" - I don't understand that at all, even in French, it doesn't make sense to me :P

    Do you want to hide the crosshair when it is "stuck" on an edge of the screen ?

  • Your "DistanceJoueurExplosion" is calculated every tick, once all the explosions happened, in event 26.

    Simply take the action that make that calculation and add it to event 22 before the "ProjectileImpulsion" destroy action and your code will work as intended.

    fixed :)

    but now, my mouse is stuck on edged of my screen haha

    and not that " fluid " when i a moving it slowly. Like steps and not following the mouse

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