Home   Help Search Login Register  

Author Topic: Where is my weapon pointing?  (Read 1765 times)

0 Members and 1 Guest are viewing this topic.

Offline alimag

  • Contributing Member
  • **
  • I'm a llama!
Where is my weapon pointing?
« on: 03 Sep 2009, 17:37:25 »
Hi,

Is there a way to calculate where my weapon (the player) is pointing.
I mean, if I had to fire a bullet where would be the point of impact.

Or is there an Arma II built in function that can do the job?

I need it to know at what object or what position on the ground the player's weapon is pointing.

Thanks in advance

Cheers

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: Where is my weapon pointing?
« Reply #1 on: 03 Sep 2009, 17:48:52 »
This should really have gone in Arma2 - Editing/Scripting General.  There are a number of ways of doing it, but I can't remember who's made scripts to achieve it, off-hand - a quick search should turn something up (presuming you haven't already).  Not sure if Spooner's view vector stuff (or something similar) will do the job.

Offline alimag

  • Contributing Member
  • **
  • I'm a llama!
Re: Where is my weapon pointing?
« Reply #2 on: 03 Sep 2009, 19:01:55 »
Hi,

Sorry for posting at the wrong place.

I've tried searching but no result. I probably does not use the right keyword(s).

Thanks for answering anyway.

Cheers


Offline alimag

  • Contributing Member
  • **
  • I'm a llama!
Re: Where is my weapon pointing?
« Reply #4 on: 04 Sep 2009, 18:58:03 »
Hi,

Thanks Pirin.

screenToWorld seems to be something that would work with a dialog. Its parameter looks like the X and Y position of a dialog element. I'm not sure yet what can be done with it.

cursorTarget seems much more interesting for what I want to do. Its a shame it does not return all the objects, including road and other builtin island objects, but just people, vehicles and big buildings.
But it's still is a start and certainly a step in the right direction. I'll see what I can do with it.

Thanks again

Cheers

EDIT

I just tried both and there is something I did not realize right away is that the player's weapon is always pointing to the center of the screen ([0.5, 0.5]). So it makes screenToWorld exactly what I needed. Fantastic.

You're a lifesaver Pirin  :good:

Cheers
« Last Edit: 04 Sep 2009, 19:19:48 by alimag »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Where is my weapon pointing?
« Reply #5 on: 04 Sep 2009, 20:03:56 »
That is technically wrong, player's weapon is pointing at center of screen ONLY if player eyes are pointing where the weapon is pointing. Also screenToWorld will not give you correct info when you are not looking to ground positions and inside view distance. Might be the command you are looking for is weaponDirection, but it requires you pass it a weapon name, so then you need to find out which weapon is handling the player. I did something for ArmA1 that might be still working for ArmA2 to find out the handled weapon.