How do I set CameraSprite between player & mouse position

  • How do I set my Camera Sprite between Player Sprite and Mouse Position?

    in a similar fashion to how nuclear throne does it - most likely using minimum &max values to stop the camera moving any further.

  • Just set your camera's position to the average position between your player and the mouse. Something like:

    X = (Player.X + Mouse.X) / 2

    Y = (Player.Y + Mouse.Y) / 2

    If you want to get fancy and control where in between the two your camera lies, you can use lerp:

    X = lerp(Player.X, Mouse.X, 0.25)

    Y = lerp(Player.Y, Mouse.Y, 0.25)

    This specific example would place the camera 25 percent of the way from the player to the mouse.

  • thanks linkman2004 luckily I was able to resolve my little problem. This was the end result I got and was going for.

    I did it by doing this. made it changeable for any later uses . no performance hit after few seconds after start of the layout -

    used windows snipping tool on windows 8.1 to get the custom screenshot

  • I wouldn't recommend using dt in a lerp function like that, as it's likely not doing what you think it is. If your FPS -- and by association, the value of dt -- starts to fluctuate, you'll find your camera jumping around. If you want smooth camera movement with dt, you should be lerping the camera position toward a fixed point between the player and mouse.

    Alternatively, you could look at my Magicam plugin, which does motion smoothing and multi-object following.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • linkman2004 Understood. I'm quite use to using it in other engines with games running at frame rate ranging from 30 -1000+ FPS. made the lerp speed more quickly understood by any group members.

    trying to not use any third party plugins as much as I can but thanks.

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