Game Development Community

dev|Pro Game Development Curriculum

GuiAnimatedCrosshairHud (TGEA)

by Matt Huston · 07/06/2007 (5:35 pm) · 7 comments

Download Code File

Tested with TGEA 1.01

Overview

Animated crosshair thats reticle scales based on player movement and if the player is aiming at an enemy. The scaling is based on how much the camera is moving (whether just looking around or actual player movement) and also what the player is aiming at. To edit values for this, check the advanceTime function. To add new objects to aim at, check the ObjectMask but remember you will need to make sure the object being added has its own CastRay function.

Add guiAnimatedCrosshairHud.cpp to your project in the engine/game/fps directory.

In guiBitmapCtrl.h, add virtual to the setBitmap function declarations.
virtual void setBitmap(const char *name, bool resize = false);
   virtual void setBitmap(GFXTexHandle handle, bool resize = false);

Compile!

Add the weapon_crosshair.png and weapon_reticle.png to starter.fps/client/ui

Replace the GuiCrossHairHud in playGui.gui with the following.

new GuiAnimatedCrosshairHud(Crosshair) {
      canSaveDynamicFields = "0";
      Profile = "GuiDefaultProfile";
      HorizSizing = "relative";
      VertSizing = "relative";
      Position = "255 175";
      Extent = "128 128";
      MinExtent = "8 2";
      canSave = "1";
      Visible = "1";
      hovertime = "1000";
      bitmap = "./weapon";
   };

#1
09/09/2007 (2:53 am)
Both your resources are excelent, thank you!
You even stuck in crosshair changing, saved me alot of work.
#2
09/18/2007 (8:05 am)
Is there a resource like this for TGE? Good job!
#3
01/12/2008 (11:27 pm)
Great!
Perfectly works with TGEA 1.0.3.
#4
01/13/2008 (6:37 pm)
I am getting this error when building, after making these changes.
Any ideas what I could be doing wrong?


3>c:\torque\tgea_1_0_3\engine\gui\controls\guibitmapctrl.cpp(22) : error C2039: 'setBitmapName' : is not a member of 'GuiBitmapCtrl'
3> c:\torque\tgea_1_0_3\engine\gui\controls\guibitmapctrl.h(14) : see declaration of 'GuiBitmapCtrl'
#5
11/18/2009 (7:48 am)
Hey,
I've updated this resource to work with 1.8.1. It's available here =)
#6
11/18/2009 (9:03 am)
And another one - this one only enlarges the crosshair when the player is translating, not rotating, and it's speed is based off the players velocity. It's up here.
#7
07/11/2010 (10:28 pm)
Hi,
I,ve updated this resource to work with T3D 1.1 Beta1.

Have a Good time~!

Download