dimanche 13 octobre 2013

Precise crosshair for activate objects

For few months, I looked for a solution to achieve a very precise "crosshair" to click on objects, with the aim to make puzzles with codes and other actions.
For a moment I thought it was not possible to be precise!

then I tried:
the "Trigger" in the UDK program is not very precise, if two triggers are side by side, so sometimes, it clicked the wrong object ...

It was John, one of the creators of XING, which gave me the basic idea of ​​"trace"...

I've been thinking and reading about how "trace" of the UDK.

The "trace" is a system that sends a "trace" between 2 points ... as an invisible laser.
And if an object crosses the trace, then you can activate an action!

But... how to send a trace between the eyes of the player, and the crosshair?

I attached an invisible object (3D viewfinder) to the player, and I positioned at a constant distance.
I made ​​him do a rotation relative to the player, remaining at the same constant distance.

It's work... just for horizontal rotation !! if i look up or down, the invisible object don't follow my regard...

Vertical problem ?
i need a new kismet nodes for the "pitch" position of my eyes, i have search on the net, and find that: GetPitch (thanks you to maker !!!)

With GetPitch, we have the degres pitch but it's a UDK units: 0 UUD (0°) to 65536 UUD (360°)

the "player eyes" stop to 0 to 12000 (up) and 65536 to 55535 (down).

Ok... i have the pitch, but it does not move my 3D viewfinder... for that i have search an others things... I used mathematics !!

for a constant distance: r (radius of a circle),
with an angle in degrees : d
cos (d) = X / r or X = r * cos (d)
sin (d) = Y / r or Y = r * sin (d)

with this new information, i can calculate with kismet the position of my 3D viewfinder in the space !

The result :

thank you for reading!
and soon to other methods

Aucun commentaire:

Enregistrer un commentaire