Jump to content
Sign in to follow this  
alleycat

Get position the cursor is aiming at?

Recommended Posts

Trying to create a script that spawns things on the spot I am aiming at. So far I only got it to work with cursorTarget. But this only works if you have a target to use it on. Is there a way to get the position of the point I am aiming at even if it is not an object?

Share this post


Link to post
Share on other sites

Thanks, but when using this like so it wont work:

		_dir = screenToWorld [0.5,0.5];


	_missile setDir [_missile, _dir] call BIS_fnc_dirTo;

The error talks about expecting number but having an array. However the wiki states that

Syntax:
   [param1, param2] call BIS_fnc_dirTo
Parameters:
   param1 - vector starting point, Position or Object 
   param1 - vector ending point, Position or Object 

http://community.bistudio.com/wiki/BIS_fnc_dirTo

Not sure why this wont work.

Share this post


Link to post
Share on other sites

Thanks that fixed the error. Now the missile flies in the 2d direction of where I am aiming at but ignores the vertical. So I added this to the script:

		_missile setVectorDirAndUp [VectorDir ( drone1), vectorUp ( drone1)];

	_missile setDir ([_missile, _dir] call BIS_fnc_dirTo);  

The first line actually makes the missile fly exactly at the point the drone is aiming at, (driver) but not where the gunner is pointing at. Any idea how to combine both solutions?

Share this post


Link to post
Share on other sites

I think the issue is that worldtoScreen always returns a z = 0 coordinate.

Share this post


Link to post
Share on other sites
The setDir command is incompatible with setVectorDirAndUp and should not be used together on the same object. Using setVectorDirAndUp alone should be sufficient for any orientation.

You need to derive your own vector based on the pos of your drone, and your target (z-value 0 is ok because it is ATL). in your last code, you setVectorDirAndUp only to the vectors of the drone object (ie, where its pointing).

im not good with vectors, so i can't help you with figuring out what your vectorDir and vectorUp would be. There probably is another Bis_fnc or command that does it...

edit:

http://killzonekid.com/arma-scripting-tutorials-attachto-and-setvectordirandup/

Edited by dr_strangepete

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×