benjf
Registered:1463800233 Posts: 4
Posted 1467641863
Reply with quote
#1
I was wondering is there a way to tell if an enemy ship is within a specified arc relative to the player ship. Essentially I want to detect if it is selected by the Weapons officer, and within the Beam weapon arc, perhaps with a different range than the beam weapons have. Thanks! Ben
ryleyra
Registered:1399599588 Posts: 3,214
Posted 1467754671
· Edited
Reply with quote
#2
There's no real way to do this, but you could test if_inside_sphere around a point in front of the player ship. You would have to figure out what the X and Z coordinates of the player ship are, though. One way is to set an X and Z variable at the start of the game, and every time it is greater than the ship's coordinate, subtract 5 from it, and every time it is less, add 5. That will end up with the variables containing the coordinates of the ship, with a granularity of 5 units. That should be more than enough to estimate where the ship's forward firing arc is. Don't forget you can also read "angle" for the ship's direction. Alternately, create a small object like an anomaly and keep it 1000 units in front of the ship with set_relative_position. Then test the distance between that object and the enemy. Of course, the crew will see something floating in space in front of them, so you should make up some explanation for what it is. Maybe you could use a custom mesh.
Mike Substelny
Administrator
Registered:1375273622 Posts: 2,990
Posted 1467818033
Reply with quote
#3
Quote:
Originally Posted by ryleyra Alternately, create a small object like an anomaly and keep it 1000 units in front of the ship with set_relative_position. Then test the distance between that object and the enemy. Of course, the crew will see something floating in space in front of them, so you should make up some explanation for what it is. Maybe you could use a custom mesh.
I agree with the custom mesh idea. You can make two nearly invisible generic mesh and constantly use set_relative_position to have them form a wedge relative to the player ship. Any object within a certain range of both generics would be between the meshes and thus inside the arc.
__________________"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight." - Winston Churchill