Posted By: Bone
vec_to_angle problem - 07/25/10 16:56
I want to move an entity to a position given by a vector.
Is the entity at the position it shall stop.
To know in which direction the entity must move I use vec_to_angle.
With vec_dist I check whether the entity at the position or not.
While the distance > 0 the entity move.
There are two problems:
If I don´t create the Entity at 0,0,0
the entity move a little bit next to the position given by
the vector.
In that case the vec_dist value is never 0.
If the entity is at 0,0,0 it works with reservations.
If the speed of the entity is too high
the vec_dist value is also never 0.
If the speed is 0.1 it works
with 0.5 it doesn´t work
I use this script:
Anybody know the problem or have an idea what I can do?
Thanks for read my post
good evening
Is the entity at the position it shall stop.
To know in which direction the entity must move I use vec_to_angle.
With vec_dist I check whether the entity at the position or not.
While the distance > 0 the entity move.
There are two problems:
If I don´t create the Entity at 0,0,0
the entity move a little bit next to the position given by
the vector.
In that case the vec_dist value is never 0.
If the entity is at 0,0,0 it works with reservations.
If the speed of the entity is too high
the vec_dist value is also never 0.
If the speed is 0.1 it works
with 0.5 it doesn´t work
I use this script:
Code:
var position = 1; VECTOR* zwei = nullvector; ENTITY* test_train; action train() { test_train = me; c_setminmax(test_train); } function move_train() { VECTOR* temp = nullvector; vec_set(temp.x, zwei.x); // vec_sub(temp.x,test_train.x); // from the vec_to_angle example vec_to_angle(test_train.pan,temp.x); // from the vec_to_angle example while(position != 0) { position = vec_dist(zwei.x,test_train.x); c_move(test_train,vector(0.1,0,0), NULL, IGNORE_PASSABLE| GLIDE); wait(1); } } function main() { level_load(""); wait(1); vec_set(zwei.x,vector(600,450,0)); // position the entity shall move to ent_create("v200.mdl",vector(0,0,0), train); // train entity on_k = move_train; }
Anybody know the problem or have an idea what I can do?
Thanks for read my post
good evening