Scroll Camera To Mouse (MOBA-esque camera scroll)

2

Attached Files

The following files have been attached to this tutorial:

.capx

Stats

2,685 visits, 3,467 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 24 Mar, 2015. Last updated 19 Feb, 2019

I came up with a simple system that allows the player to see further in front of them by holding shift down, centering the camera between the player's position and the mouse position.

First, you'll want to add the ScrollTo behavior to your player. Next, you'll create a sprite, just use the paint bucket and fill the sprite with black. Name it something along the lines of, "MousePos", and you'll want to add the ScrollTo behavior to this as well. Scale the sprite down to around 5 x 5 or 10 x 10 and set the opacity to 0. Finally, you'll need to add the Mouse and Keyboard input to your project.

Now, we'll move on to the Event Sheet!

I'll write the code out using the format - Event:Action.

System -> On start of layout: MousePos set ScrollTo disabled

System -> Every Tick: set MousePos position to Mouse.X, Mouse.Y

Keyboard -> Key is Down (Shift): set MousePos ScrollTo enabled

else: set ScrollTo disabled

That's it!

  • 0 Comments

Want to leave a comment? Login or Register an account!