Detect where is the player looking at and change cursor

This forum is currently in read-only mode.
From the Asset Store
Mouse cursor is something that the player controls and sees all the time, that's why it is so important to make it cool!
  • Hi there.

    I'd like to ask: is there some kind of way to detect where is the player looking at?

    Imagine it's a birdseye shooter. The mouse movement changes the player's angle. If the player looks at a sprite, a text message would appear. Kind of like in HL2: EP. 1 (or 2, I don't remember), where we look outside a window and a monster spawns behind us.

    Also, I'd like to know if there's any way to change the cursor to a crosshair, but only in-game.

    Thanks in advance,

    velosotiago

  • You can add to the player the Line of Sight behaviour.

    And as for the cursor, add the "mouse and keyboard" object. Then, in the events, add:

    -Start of Layout : set cursor invisible;

    Make the crosshair sprite and give it the mouse behaviour. This should make that sprite follow the hidden cursor.

    Tip: you can even give that sprite some animations, so when the player shoot, the crosshair changes.

  • Nice! I'll try both and post how it went later.

    Btw, is there any way to make it so the mouse can't go out of the game window except when in pause? (being ESC the pause key, if that helps)

    Thanks in advance,

    velosotiago

    EDIT: Both work like a charm! Thanks alot!

  • BUMP

    Can someone answer the question I asked in the last post?

    Thanks in advance,

    velosotiago

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'll let you figure out how to do a state when in pause.

    Mouse set x to clamp(mousex,0,displaywidth)

    Mouse set y to clamp(mousey,0,displayheight)

    You'll want to add some way to exit the program, as you cant get to the close button in the frame, and esc is the standard for exiting via keyboard.

  • Yeah, I'd make a Exit to Menu button in the pause menu.

    (a 'Exit' button would be useless because when in the pause menu the mouse would be able to go out of the window...)

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