How do I Make a wall, my cursor cant pass

  • How about attach a custom cursor sprite pinned to the mouse movement, and have that get stopped by walls. Then the player has to reaquire the cursor?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you cant directly pin to the mouse movement, and w/o setting the position directly to the mouse, you cant get a very responsive cursor...

  • it seems like theres no solution...

  • To stop the cursor from clipping through walls you need to use a loop to check all positions between the old mouse position to the new position for a collision.

    like this or the attached capx:

    repeat distance(cursor.x, cursor.y, mouse.x, mouse.y) times

    ---- cursor: move 1 pixel at angle angle(cursor.x, cursor.y, mouse.x, mouse.y)

    -------- system: pick wall overlapping cursor.x, cursor.y

    -------------- cursor: move -1 pixel at angle angle(cursor.x, cursor.y, mouse.x, mouse.y)

    -------------- stop loop

    There are other ways such as doing a raycast from the old mouse position to a new one but c2 has nothing built-in for that. You could also do wall sliding for a more pleasing motion instead of getting stuck on walls, but again there's nothing built in to handle that.

  • Your a life saver, cant thank you enough!!

  • the cursor bounces when its in a corner :/ it vibrates, i can not for the life of me figure out how to stop it :/

  • It doesn't vibrate for me. In the capx I subtracted 1 from the repeat loop to stop jitter when the mouse isn't moving.

    repeat distance(cursor.x, cursor.y, mouse.x, mouse.y)-1 times

    Maybe that can help? Maybe use 2 instead?

  • aha, it was one of the behaviors i had on the cursor, its fixed, but it still moves when i move the mouse on the other side of the wall, as i move it around, the cursor moves left/right/up/down one or 2 pixels, still in the wall.

  • It doesn't vibrate for me. In the capx I subtracted 1 from the repeat loop to stop jitter when the mouse isn't moving.

    repeat distance(cursor.x, cursor.y, mouse.x, mouse.y)-1 times

    Maybe that can help? Maybe use 2 instead?

    Where is this stuff supposed to be put in?? I too want to know how to move through walls of the same game. Thanks

  • Cursors

    In event 4 of the capx I posted. In the capx I use -1, and in the quote I'm suggesting to use -2.

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