Set Scroll to Playersprite + Mouse

0 favourites
  • 6 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hey, so I want to have the scrolling set relative to the player sprite's position and the mouse position. Currently I'm using:

    Every tick > Scroll to (abs(Sprite.X+Mouse.X)/2), (abs(Sprite.Y+Mouse.Y)/2)

    which works OK, but I want the view to centre more around the player sprite so that there's more of a "pull" to the player's position. At full stretch the view should centre around 1/4 of the distance between player and mouse, originating from the player. I've tried a few things with the numbers and I'm sure it's simple, but I can't seem to figure it out!

  • This can be useful.

  • Thanks - there's no way to do it just by adjusting my initial event? I'd have thought that since I've already got the effect I want and just want to adjust the parameters a bit it'd be easy, but maths makes my head hurt

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, maths and programming - not my strong side.

    That screenshot on top - result of my headache

  • I would create an invisible sprite with the scrollto behavior

    System every tick

    Sprite set position to object player

    Sprite move = 0.25*(distance(player.x,player.y,mouse.x,mouse.y))px at angle = angle(player.x,player.y,mouse.x,mouse.y)

  • Thanks! XpMonster 's solution worked fine for me, I just can't help thinking there ought to be a neater way to do it.

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