Basic FPS / Mouse Looking

By now there have been plenty of discussions on the Discord's Support about FPS games. Turns out that the "First Person Mode" button that people see when making their projects is pretty tantalizing. Sadly, it's easy to get stuck beyond that.

In this tutorial you'll learn how to do the bare minimum FPS. Starting from scratch and ending with locked mouse-look and the basic movement. It's not too complex, but it's the kind of thing that's really easy to mess up if you don't do it properly.

Making the project​

For an FPS, there's a few options we'll need to select. I have all of them highlighted in red in this image.


For the assets we'll be using in this tutorial, you should also change the tile size to 64. Otherwise if you're using your own assets, you can do whatever you want with it.

Next you'll need to create a map. Nothing about it really matters, we just need a place to spawn the player. We'll also need a tileset so the world is actually visible. To have some parity, use this awful test tileset I made.


Create a new tileset in the Database under the Maps section and plug this image into the first slot of the Structure Tiles. If you did it right, there should be no errors. Back in the map, you should see the tileset you just made right below the middle of the "Standard" tilesets in the button that looks like a square mountain. Press the button that looks like a paint bucket on the main editor window and click into your map to fill it with the tile.

If you press play now, it'll look like this.


To add some walls to our freshly made map, click under the middle of the "Modifiers" Tilesets and click the number 4, then drag a hollowed out box around the map.



We now have a basic room to continue the tutorial in!


Looking Around - Part 1 (Virtual Keys)​

If you play the project, you'll notice that the camera is currently static. So now we come to the part where most people get confused. How do you look around when that behavior doesn't seem built in?

Well first, we start with Virtual Keys.

It's true that RPG Architect currently isn't doing anything with your mouse, and that's because it's not connected to any Virtual Keys. Virtual Keys are how the engine registers Input. Every project starts with a small amount of generic keys that do generic actions. Movement, menus, that sort of stuff.

You can see the default Virtual Keys by opening the Database and scrolling to its menu near the bottom.


For our own needs, we'll need to create some new Virtual Keys to handle looking with the Mouse.

Resize the Virtual Key menu to 11. Call the first new Key something along the lines of "Mouse X Negative". Press the Plus icon for Mapping and change the source of the New Mapping to Mouse. Click Axis and then click X Axis - Negative.

Do this three more times, all for the values on the X and Y axes.


You might have noticed I ticked one extra thing, and that's "Store Change in Global Variable". Basically, we're gonna do the exact same thing you just did again.

Back in the map menu, click the button that looks like a square root icon near the top right. This is the Global Variable menu. Resize the amount of Variables to 4 using the resize button and hook up the correct axis values to the variables. Make sure their names match up, for your own sanity.

We are now properly tracking the movement of the player's mouse, but it's not moving yet.

Looking Around - Part 2 (Locking the Mouse)​

Before we actually get to moving the camera, we need to do one more thing, and that's locking the Player's Mouse. There's a few ways to do this, but here we'll create and then remove an Entity Definition when entering a map. The process here is a little irritating, so I'll give you the entity for free.

{"Data":{"ID":0,"Locals":{"Switches":[{"Name":"A","Value":1}],"Variables":[]},"Name":"Lock Mouse","Position":"0,0,0","Scripts":[{"$":"EntityScript","Annotations":[],"CharacterModel":{"BackfaceCullingMethod":0,"HueShift":0,"IsCycling":0,"IsModel":0,"SpriteBorderThickness":0,"SpriteDuration":100,"SpriteFrames":3,"SpriteLayers":{},"SpriteOrientation":4,"SpriteOrientedAroundCenter":1,"SpriteRegion":"0,0,0,0","UseSpriteLayers":0,"Scale":"1,1,1","Translation":"0,0,0"},"ColliderPoints":[],"CycleAnimation":0,"Delay":0,"Direction":5,"FacePlayerOnInteraction":0,"FixDirection":0,"IgnoresCollision":0,"IgnoresGravity":0,"IgnoresObstacles":0,"IsClipping":0,"IsDirectionUpdated":1,"IsPushable":0,"IsRegisteringIgnoredCollisions":0,"MovementType":0,"PreventCollision":0,"PreventFalling":0,"RecycleAnimation":1,"Rotation":"0,0,0","Speed":1,"SpriteShape":0,"SuspendMovementOnInteraction":1,"Commands":[{"$":"ChangeMouseCommand","IsMousePositionChangeable":{"IsGlobalSwitch":0,"IsLocalSwitch":0,"IsValue":1,"Value":0,"SwitchIndex":0}},{"$":"SwitchCommand","Random":0,"Value":0,"Index":0,"IsLocal":1}],"Conditions":[{"$":"LocalSwitchCondition","Index":0,"Value":1}],"Interactions":[{"$":"AutomaticInteraction"}]}]},"TypeName":"MAR.Game.RPGCore.Models.Maps.RPGEntity"}

Yeah, this is the entity. Don't believe me? Try pasting that text into your Entity Definitions under Map in the Database. It should work fine and create a new "Lock Mouse" entity.

What this entity does is very simple. It's an automatic entity that, upon spawning, will lock the player's mouse. Right after doing that it'll set one of its local switches off. Since it depends on that switch as a condition, the entity will become effectively disabled after executing its logic. Since it's not literally removed, this keeps the entity opened up to being manipulated later (though we won't be doing anything with it here).

To make this entity spawn in your map, we'll use a generic solution that'll make it apply to every map.

Under the "Configuration" Tab in Maps, scroll down until you see the "Enter Map" Script. Right click and create a new "Spawn Entity" command under "Entity and Vehicle". Spawn the Entity Definition we just made. I like to set its position values to something crazy so they can't bother anything.

The next time you open your game, you won't be able to move your mouse! You better get used to Pressing those Alt-F4 keys!

Alternatively, if you don't want to go to the work of using an Entity Definition, you could simply spawn the "Change Mouse Mode" operation in the Enter Map Script itself.

Looking Around - Part 3 (Actually Looking)​

I lied when I said there was only one more thing to do, there's actually one more little thing to do. It's so small though, that it barely matters. In the "Video Configuration" Settings under System, I want you to just change two values. Scroll down to X Rotation. Change the minimum to 181. Change the Maximum to 359. Congratulations. That's it!

Now we can ACTUALLY, FINALLY make the player look around. It's so easy in fact, you might be underwhelmed.

Remember those Virtual Keys we made earlier? We're gonna put some stuff in them. In the Ongoing Script of the Keys we made, I want you to throw an "Adjust Camera" operation, which is under "Map". For every key, hook it up to the related values. Tick "Use as Delta Values" near the top of the Adjust Camera operation. For the Mouse X axis, throw the values into the Y (Yaw) of the camera. For the Mouse Y Axis, throw the values in the X (Pitch) of the camera and Tick Clamp.

If all goes well, you should be able to look around now. There's one more tiny problem that we'll fix right now.

The mouse movement is a little jerky, and that's because of how our axis values are being read. We're only turning full degrees on the camera, which is WAY too much.

All you need to do to fix this is add a "Change Variable" Operation for every relevant Variable and multiply it by a small number like 0.2. This makes the mouse looking go from jerky to almost too smooth.

Here's an example showing the "Mouse X Negative" Virtual Key.


This should be all you need to have a working FPS with mouse look. There's plenty you could do to extend this. Crouching, Jumping, Footstep noises, etc. You'd be surprised how good RPGA is at making an FPS!

If you have any questions or think this could be improved, tell me.
Last edited:
Very nice.

A thought -- you could potentially direct folks on how to setup some base global variables (like you are), and then also give them the Virtual Keys to copy.

RPG Architect allows you to paste data in clear-text (as you displayed above). Can definitely do it some more!
Well done, like the way you laid it out. Its easy to follow.