c_move question

Posted By: scrooge313

c_move question - 03/03/08 23:24

Hi,

I have following problem:
I want to move an entity from one vector to another.
For example (10,20,10)->(20,20,10)
When I use a while-loop with my.x+=1 I have the problem that I cannot use time_step.

Thats why I want to try it with c_move.

Code:
 while (x_my+10!=x_my_now){
x_my_now=my.x;
c_move (my, vector(0,0,0), vector(y_move * time_step,0, 0), ignore_models);
}



But now, the movement doesn't finish exactly at that vector I want it to have because of time_step.

Do you have any ideas for solving my (little) problem.

THANKS.

Posted By: demiGod

Re: c_move question - 03/06/08 23:46

A vector is magnitude but also direction, you will need some more calculations. Using vec_accelerate its a possibility, change the target vector (0,0,0) to the vector you want to move and test it.

Code:

var vSpeed;
var vTarget[3] = 0,0,0;
var distBetweenObjTarget[3];

action testObj
{
var vAccel;
var vMove;
var iSpeed = 2;
while(1)
{
//turn towards target
vec_set(temp,vTarget.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);
//calculate distance between obj and target
distBetweenObjTarget = vec_dist(my.x,target.x);
//calculate velocity to apply
vAccel.x = iSpeed * distBetweenObjTarget[0];
vAccel.y = iSpeed * distBetweenObjTarget[1];
vAccel.z = iSpeed * distBetweenObjTarget[2];
vec_accelerate(vMove, vSpeed, vAccel, 0.5);
c_move(my, vMove, nullvector, glide);
wait(1);
}
}


Posted By: scrooge313

Re: c_move question - 03/19/08 00:50

Thank you very much. Cause of your help I could solve my problem.
© 2024 lite-C Forums