Pages

Friday, November 29, 2013

[TUT] Cool "3D" target HUD

These days i wanna show how you can use some game functions to produce an cool "3D" target HUD to use in your scripts, this is an preview of what I'm speaking about:



Download the sample script right here.

The idea consists in draw checkpoints/coronas about 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 require the following objects to make this code work:


right here we will retailer the possible targets

this will be the interval of the targets search

this object will give offset positions about the target

this is just an variable to support us create an rotation impact for the target HUD, we will boost 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 ought to generate the object, pick an model with small volume to steer clear of collisions with other issues, we also set this object to be invisible, without collisions and with freezeposition set to correct, the wait(500) it's an single delay to stay away from script crash at first begin, simply because when game finishes loading the object creation can fail:


Ok, first let's search for the achievable targets, in the tick let's check if the timer variable (timeWaitSearchTargets) it really is much 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 automobile is close sufficient to the aim, we will do it only if user is pressing Aim key and if the targets list exists:


I'm making use of this method to discover the targets.

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


How it operates:

1st we set the targetAux object position to player position, you can use existing camera position, but the result its nearly the identical
Then we set the rotation of this object to be the very same of the camera
Now we just want to use the method GetOffsetPosition to detect the position around it and primarily based on this we can define the Offset position about the target:

To get the position above the target:


Bellow target:


on the Left:


on the proper Right:



This is an easy idea that functions extremely fine, is not the best option but performs fine :)

You can use lights and coronas as well, the outcome will appear much better.
[TUT] Cool "3D" target HUD
9out of 10 based on 10 ratings. 9 user reviews.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.