Sunday, 7 April 2013

[TUT] Cool "3D" target HUD

Today i wanna show how you can use some game features to create an cool "3D" target HUD to use in your scripts, this is an preview of what I'm talking about:



Download the sample script here.

The idea consists in draw checkpoints/coronas around the target, we will use the native function DRAW_CHECKPOINT to draw the checkpoints.

Download the sample project here, let's use this project as the base for this tutorial.

We will need the following objects to make this code work:


here we will store the possible targets

this will be the interval of the targets search

this object will give offset positions around the target

this is just an variable to help us create an rotation effect for the target HUD, we will increase it and apply to the Y value of the targetAux object rotation

this will set the actual target so we can kid with it :)


When the script loads we should create the object, choose an model with small volume to avoid collisions with other things, we also set this object to be invisible, without collisions and with freezeposition set to true, the wait(500) it's an single delay to avoid script crash at first start, because when game finishes loading the object creation can fail:


Ok, first let's search for the possible targets, in the tick let's check if the timer variable (timeWaitSearchTargets) it's less than zero, then we will reset it to 300 and search for the targets, so each 300 ms we will update the targets list:


Now we will reset the actual target to nothing and run the targets list to see what vehicle is close enough to the aim, we will do it only if user is pressing Aim key and if the targets list exists:


I'm using this method to find the targets.

Now that we have our target we can draw the checkpoint around it:


How it works:

First we set the targetAux object position to player position, you can use current camera position, but the result its almost the same
Then we set the rotation of this object to be the same of the camera
Now we just need to use the method GetOffsetPosition to detect the position around it and based on this we can define the Offset position around the target:

To get the position above the target:


Bellow target:


on the Left:


on the right Right:



This is an simple idea that works very fine, isn't the best option but works fine :)

You can use lights and coronas too, the result will look better.

Related Posts:

  • [TUT] Settings file - Saving and loading .INI config infoToday i wanna show how you can load and save configuration in .INI files, this is very useful to set customizable things in your script like Hotkeys, timeouts, offsets, etc..Download the sample project here, let's use this pr… Read More
  • [TUT] Particle effectsToday let's play with particle effects, it's simple and give an good look to the script effects.Download the project here.As you probably know an particle effect (PTFX) in GTA IV is the effect of bullet impacts, water splash,… Read More
  • RequestsLet me write here some mod's requests:Alessio CalandrellaHi, can u help creating a little script.The Script must work in this way:Press Alt+Z to get the ems bag.The bag will attach to the player.Jebus28279Hey man, what's up? … Read More
  • Iron Man IV script mod - Possible problems and possible solutions :)In this post i wanna show some possible problems that you can have with Iron Man IV script and some possible solutions.First of all, if the script don't work, you did something wrong or have wrong or incompatible software (Cr… Read More
  • [W.I.P.] Weed script ^^Why not? Fear? No way, I'm atheist, i don't fear gods do you think that i will fear man? haha kidding ;)This script is an (not expected) request that will bring some cool things to GTA iV, you will be able to buy and smoke so… Read More

0 comments:

Post a Comment