Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Aim angle
#2
For basics of trigonometry, all you need is these three definitions:
[Image: TrigonometryMnemonic_1000.gif]

To calculate the angle, we'll use sin(). For our purposes:
h is the distance in 3D between objects. h = distance(this.position, other.position)
o is difference in height between objects. o = other.position.z - this.position.z

Additionally you need to know that while sin takes an angle as parameter and returns a proportion, there is an inverse function that takes a proportion and returns an angle, called arcus sinus (asin()).

So the basic targetting code is:
Code:
float h = distance(this.position, other.position);
float o = other.position.z - this.position.z;
float angle = asin(o/h);
aim(angle);

(be aware that I wrote this without checking in game so there may be an error somewhere)


For detecting obstacles in front, you can use radar() with the extended syntax (see SatCom for more info). To detect water you need topo() function and some more trigonometry.


Messages In This Thread
Aim angle - by clop1000 - 07-05-2016, 04:13 PM
RE: Aim angle - by krzys_h - 07-05-2016, 04:27 PM
RE: Aim angle - by clop1000 - 07-06-2016, 09:29 AM
RE: Aim angle - by radioactivity - 07-06-2016, 02:24 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)