Showing posts with label camera. Show all posts
Showing posts with label camera. Show all posts

Saturday, November 20, 2010

Allar’s Dev Diary #14: Day 3, Tower Defense Side Project

Day 3 (11/20/2010)


7. Aiming With The Mouse


Now that I got the camera set up yesterday and played a lot of Vindictus, its time to get back to work. The next step is to get the player to aim towards where their mouse instead of in the direction the player camera is facing. This way movement and aim will be separated and allow for interaction with the world with the freedom of rotation but locking movement to the camera axis. Basically, the player will be controlled like most top-down shooters. Now for this project I am currently using the September build of UDK even though the October build is out as this project is also meant to help some classmates with their project which is currently September based. The reason I bring this up is that the October build of UDK strips out all UIScene functionality completely and everything related to it and in the past the class UIRoot was my primary way of accessing mouse coordinates. This means that for my project to not need a major reworking in the future I would have to find a new way to grab mouse coordinates. Now I looked all over the UDK development code and I could not find a straightforward way to do so. If there is a easier way than the process that I went to that I will go over, please let me know. The way I did it relies on a SWF to store mouse coordinates which then UnrealScript grabs. Its a little odd but it works flawlessly once set up correctly. I figured that if I used ScaleForm to grab mouse coordinates, Epic won't be scrapping ScaleForm any time soon.

The first thing we are going to need to do is to replace the UT HUD with our own ScaleForm based HUD. As fancy as the UT HUD is, I'd rather have my own. Also, I need to create mouse coordinate functionality without relying on the old hud's Canvas to use DeProject, which I'll get into later. For now, I don't need anything fancy in my HUD except a mouse cursor which will indicate where the player is aiming and will also serve as a cursor for UI interaction with HUD menus and things. Time to start up Flash and build me a HUD. I am using a trial version of Flash CS5 at the moment.

With Flash CS5, I have already set up my ScaleForm extension and my ActionScript settings. If you have not dealt with ScaleForm and Flash before, I strongly encourage checking out my ScaleForm series here. With my new flash document open, I went ahead and drew myself a cursor with the flash tools, and this is what I came up with:


Friday, November 19, 2010

Allar’s Dev Diary #13: Day 2, Tower Defense Side Project

If you don't know about my Tower Defense Side Project, please read Day 1 here.

Day 2 (11/20/2010)


5. Creating The Camera


I've done a few third person cameras before so I was able to implement this system within a half hour. I did research some examples of isometric cameras beforehand however, and I ended up starting with this tutorial here (at X9 Productions) by Christian Roy. His provided code was simple and elegant so it would serve as a perfect slate to base my camera logic on. After implementing his tutorial code however, I found that my 'isometric' camera was only being properly shown if I typed behindview in console, but this is because I implemented it as a child of UTGame and not GameInfo. Normally I don't derive from UTGame but in the case of this project I did not want to have to deal with creating a new code base, but this also causes small issues like these. My solution was to simply force a SetBehindView call on the Pawn during its PostBeginPlay function and that remedied things for the most part. I also had to edit the CameraOffset and the CameraScaleMax variables to get the angle I wanted the camera to be at. Roy's tutorial implementation does not support camera zooming (however the source code he provides for download does, but I chose to implement it differently). I wanted it so the camera would stay locked and you can't zoom or rotate it unless you held down the middle mouse button and then moved the mouse or scrolled. In order to accomplish this, the first thing I had to do was to edit DefaultInput.ini and add the following bindings:

[csharp]//DefaultInput.ini
.Bindings=(Name="MiddleMouseButton",Command="AllowCameraMovement true | onrelease AllowCameraMovement false")
.Bindings=(Name="MouseScrollUp",Command="HandleMouseScroll true")
.Bindings=(Name="MouseScrollDown",Command="HandleMouseScroll false")[/csharp]

This way two functions would be called, one when the MiddleMouseButton was pressed or released, and one when the scroll wheel was scrolled. AllowCameraMovement(bool bEnable) toggles whether or not the camera should rotate or zoom with the mouse, and HandleMouseScroll(bool bUp) handles what to do when the mouse is scrolled up or down.

Sunday, September 12, 2010

Thursday, April 8, 2010

HTWeapon: Part 6 - Hiding First Person Mesh In Third Person

Video Version


Subject: HTWeapon: Part 6 - Hiding First Person Mesh In Third Person
Skill Level: Beginner
Run-Time: 5 minutes
Author: Michael Allar
Notes: How to make your weapon deal damage upon firing.

Streaming:     720×480 1920×1080

Download:     Low-Res (18MB) Hi-Res (22MB)

Written Version


Subject: HTWeapon: Part 6 - Hiding First Person Mesh In Third Person
Skill Level: Beginner
Author: Michael Allar
Notes: How to hide your first person mesh while in third person

No written version here, just code. If you want to write this up, contact me.

Wednesday, March 31, 2010

Creating A Third-Person Camera

Where is the video version? Its below the written version, because the written version came out much better.

Written Version


Subject: Creating A Third-Person Camera
Skill Level: Intermediate
Author: Michael Allar
Notes: How to implement a third person camera.