Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 1,258 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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 | chip programmers | 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