﻿ Aim angle

 Aim angle clop1000 PracticeBot Posts: 18 Threads: 7 Joined: May 2016 Reputation: 0 #1 07-05-2016, 04:13 PM (This post was last modified: 07-05-2016, 04:14 PM by clop1000.) My bad, i absolutely don't know a math and geometry. Can someone advise me about how to determine an angle between a bot and a target. Of course it's for Flying objects. I will really appreciate your help if you can explain it step by step, cos i don't know what COS and SIN means. (i know words , but don't know how it works)   And additional one - is there anyway to knowing is there a water or an another obstacle in front of you? I am making manual driving bot (without using - goto, and even try don't use a move functions, only using motor())     BTW - it's such a cool game! Thx everyone for your work! krzys_h The Programmer Posts: 828 Threads: 26 Joined: Oct 2012 Reputation: 113 #2 07-05-2016, 04:27 PM For basics of trigonometry, all you need is these three definitions: 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. clop1000 PracticeBot Posts: 18 Threads: 7 Joined: May 2016 Reputation: 0 #3 07-06-2016, 09:29 AM Thx! Now i know the basics of trigonometry!)☺ I finally i understood meaning of Sin,and other unknown things ☺ Your post is fantastic. radioactivity TrackedShooter Posts: 263 Threads: 3 Joined: Dec 2012 Reputation: 18 #4 07-06-2016, 02:24 PM Colobot - entertains and teaches "Deep within all of us lives an idiot, and if you let that idiot dictate your decisions your live is going to be rough." ~ Ryan Letourneau, 2k15 « Next Oldest | Next Newest »