Scroll Camera To Mouse (MOBA-esque camera scroll)

Attached Files

The following files have been attached to this tutorial:

.capx

Stats

1,389 visits, 1,909 views

Tools

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

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