Distance between 2 objects
#1

The title says it all, is it possible to find a distance between two objects that are moving? I have been looking through the forums, attempted to create my own native(obiviously didn't work), found distance between two points(x1,y1,z1 and x2,y2,z2) nothing of that worked out the way I wanted. So I am wondering is it possible to get the distance?

My second question would be: When you use MoveObject, is it possible to set it so object doesnt go through the wall? Or is there any other function for moving objects?

Thanks in advance.
Reply
#2

Use a timer, then use GetPlayerDistanceFromPoint (maybe? )

MoveObject will only move the object to the place you specified. So you can make sure it wont go through a wall by moving it manually to the place you want.
Reply
#3

Quote:

Use a timer, then use GetPlayerDistanceFromPoint (maybe? )

MoveObject will only move the object to the place you specified. So you can make sure it wont go through a wall by moving it manually to the place you want.

I dont know how this could help, I am currently creating a moving objects like rocket, it moves to x and y location + 20.0 so u cant assume where will it move. If you come near the wall and do the cmd for moving the object it will move through the wall 20.0...
Reply
#4

Amm i think you should use something like this

pawn Код:
new Float:Obj1X,Float:Obj1Y,Float:Obj1Z,Float:Obj2X,Float:Obj2Y,Float:Obj2Z;
new Float:Distance;
GetObjectPos(object1id,Obj1X,Obj1Y,Obj1Z);
GetObjectPos(object2id,Obj2X,Obj2Y,Obj2Z);
Distance = floatsqroot(((Obj2X-Obj1X)*(Obj2X-Obj1X))+((Obj2Y-Obj1Y)*(Obj2Y-Obj1Y));
//then put it the distance var in a formated string display it to the player , done
For Moving Object You need to set a timer which repeatedly gets the Obj1 X,Y,Z And Obj2 X,Y,Z and Then you just need to put those things in that formula

Just Give it a try it should work , its based on distance formula
Reply
#5

Quote:

Amm i think you should use something like this

pawn Code:
new Float:Obj1X,Float:Obj1Y,Float:Obj1Z,Float:Obj2X,Fl oat:Obj2Y,Float:Obj2Z;
new Floatistance;
GetObjectPos(object1id,Obj1X,Obj1Y,Obj1Z);
GetObjectPos(object2id,Obj2X,Obj2Y,Obj2Z);
Distance = floatsqroot(((Obj2X-Obj1X)*(Obj2X-Obj1X))+((Obj2Y-Obj1Y)*(Obj2Y-Obj1Y));
//then put it the distance var in a formated string display it to the player , done

For Moving Object You need to set a timer which repeatedly gets the Obj1 X,Y,Z And Obj2 X,Y,Z and Then you just need to put those things in that formula

Just Give it a try it should work , its based on distance formula

It works perfectly when I use SendClientMessage, I will check it if it works with other things later on.. Thank you very much mate.
Reply
#6

Quote:
Originally Posted by Harry_F.
Посмотреть сообщение
It works perfectly when I use SendClientMessage, I will check it if it works with other things later on.. Thank you very much mate.
No Problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)