How to find the distance between two objects (EASY)
  
    
    	
    	| 
        Author: |  canazza
         | 
        Submitted: |  25th February, 2003
         |  
        | 
        Views: |  7004
         | Rated: | 
        
        		
         |  
         
     | 
   
    
       
      
      
Finding the distance between two objects (ObjA and ObjB) is simple and requires the use of pythagoras theorem (that's the thing in maths all about triangles)
 
 
Pythagoras theorem states:
 
The Square of the Hypotenues of a right angled triangle is equal to the sum of the squares of the other two sides, I.E.:
 
H² = a² + o² where a and o are the other two sides.
 
 
H is basically the distance between the two objects in question.
 
 
a and o are the differences in the y co-ordinates and the x-co-ordinates
 
 
You will need the Math object or the Amath object for TGF (i'm not sure about MMF, i think they are built in functions)
 
create a new event in MMF/TGF using the COMPARE TWO GENERAL VALUES box.
 
 
Set the top box to SQUAREROOT( ("Xpos of obja" - "Xpos of objB")² + 
 
("Ypos of obja" - "Ypos of objB")²)
 
then you can test it against other values (IE a counter, or a set number)
 
 
wasn't that simple?
 
 |  
  
 
	
	 
	
	 
	
	
		
		
  
	
	
 | 
  canazza 
Registered  18/12/2002
 Points  850
  
 
	 |