follow the mouse with lag

  • how do i get a sprite to follow the mouse with some sort of lag

    i know this works, but it is very rigid:

    system -> every tick --> set sprite Y to Mouse.Y

    any suggestions on how to get the sprite to lag behind the mouse a bit and when the movement stops the sprite "settles" into position

    ???

  • db.tt/p9xWaV6R

    How's that? It took a couple events and an array to make it happen, but it seems to get the job done. As far as I can see there's no way to make the main cursor invisible, though...

  • Can you decrease the speed of the sprite when it gets x number of pixels from the mouse?

    distance(sprite.X, sprite.Y, Mouse.X, Mouse.Y) <= 100

    Set sprite speed

    Going off memory here. Am at work and no access to test it out. Lol

  • Thanx. I'll try them both out later today

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • it depends what you want.

    Make the object have a 'bullet' behavior.

    If you want it to just move towards the mouse, just set the bullet speed to whatever you want and then every tick set the angle towards position of mouse_x, mouse_y.

    if you want it to move at speed relative to its distance from the mouse, do the same as above, but every tick set the bullet speed to distance(object.x,object.y,mouse.x,mouse.y) / modifier + modifier

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