Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 12,420 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
c_move question #186860
03/03/08 23:24
03/03/08 23:24
Joined: Dec 2007
Posts: 8
S
scrooge313 Offline OP
Newbie
scrooge313  Offline OP
Newbie
S

Joined: Dec 2007
Posts: 8
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.


Re: c_move question [Re: scrooge313] #186861
03/06/08 23:46
03/06/08 23:46
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
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);
}
}




" If i disappear without say anything that´s because i´m dead. "
Re: c_move question [Re: demiGod] #186862
03/19/08 00:50
03/19/08 00:50
Joined: Dec 2007
Posts: 8
S
scrooge313 Offline OP
Newbie
scrooge313  Offline OP
Newbie
S

Joined: Dec 2007
Posts: 8
Thank you very much. Cause of your help I could solve my problem.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1