|
0 registered members (),
3,106
guests, and 27
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Check If Collide With Object?
[Re: 3run]
#368792
04/28/11 14:02
04/28/11 14:02
|
Joined: Apr 2011
Posts: 12 Sweden
Linus371
OP
Newbie
|
OP
Newbie
Joined: Apr 2011
Posts: 12
Sweden
|
This is my final code after I did that thing to check how close it was:
ENTITY* playerCar;
action dumper(){
playerCar=me;
var speed = 4; // Var för bilens fart
var turn_speed = 7; // Var för turn speed
var grav = -7; //Var för Gravitation
// Sparar start positioner så att dom kan reseter seneare!
var startX=me.x;
var startY=me.y;
var startZ=me.z;
var startPan=me.pan;
// Annat Setup:
camera.tilt=-50;
my.ambient = 80;
while (1){
// Om man kör framåt:
if (key_w){
c_move(me,vector(speed * time_step,0,1*time_step),nullvector,GLIDE | IGNORE_FLAG2);
if (key_a){
my.pan+=turn_speed*time_step;
}
if (key_d){
my.pan-=turn_speed*time_step;
}
}
// Om man kör bakåt
if (key_s){
c_move(me,vector(-speed * time_step,0,1*time_step),nullvector,GLIDE | IGNORE_FLAG2);
if (key_a){
my.pan-=turn_speed*time_step;
}
if (key_d){
my.pan+=turn_speed*time_step;
}
}
// Gravitation :3
c_move(me,nullvector,vector(0,0,(grav) * time_step),GLIDE | IGNORE_FLAG2 | IGNORE_ME);
// Om man ramlar
if (me.z<-200){
// Reset Position
me.x=startX;
me.y=startY;
me.z=startZ;
me.pan=startPan;
}
// Flyttar kameran till rätt ställe >:3
camera.x=me.x-180;
camera.y=me.y;
camera.z=my.z+280;
wait(1);
}
}
action goal(){
while(1){
while(playerCar == NULL){
wait(1);
}
if(vec_dist(me, playerCar) < 500){
level_load("leve2.wmb");
wait(2);
}
wait(1);
}
}
function main()
{
level_load("mainLevel.wmb");
}
But when I get close it, Nothing happens! What have I've done wrong? 
|
|
|
Re: Check If Collide With Object?
[Re: Walori]
#368799
04/28/11 14:40
04/28/11 14:40
|
Joined: Apr 2011
Posts: 12 Sweden
Linus371
OP
Newbie
|
OP
Newbie
Joined: Apr 2011
Posts: 12
Sweden
|
vec_dist(me, playerCar) one small mistake, vec_dist requires VECTOR's, now you're using ENTITY pointers, so change:
Original: vec_dist(me, playerCar)
Modified: vec_dist(me.x, playerCar.x) Why me.x? Should I not check both z,x and y? :S And If I use your modified code, It wont still work :C
Last edited by Linus371; 04/28/11 14:45.
|
|
|
Re: Check If Collide With Object?
[Re: Linus371]
#368801
04/28/11 15:16
04/28/11 15:16
|
Joined: Feb 2010
Posts: 320 TANA/Madagascar
3dgs_snake
Senior Member
|
Senior Member
Joined: Feb 2010
Posts: 320
TANA/Madagascar
|
Hi, Yes you are right, but that code is also right  . me is an entity pointer, but you need to pass a VECTOR to the function, with Lite-C, you need to pass the first element of a vector and the next 2 elements will be taken automatically. The same goes for entity skills (ex:
vec_set(my.skill1, vector(1, 2, 3));
to set both skill1, skill2, and skill3), and entity rotation (you only need to pass the entity pan as a vector parameter of a function). Hope you understand. Best regards.
|
|
|
Re: Check If Collide With Object?
[Re: 3dgs_snake]
#368808
04/28/11 15:52
04/28/11 15:52
|
Joined: Apr 2011
Posts: 12 Sweden
Linus371
OP
Newbie
|
OP
Newbie
Joined: Apr 2011
Posts: 12
Sweden
|
Hi, Yes you are right, but that code is also right  . me is an entity pointer, but you need to pass a VECTOR to the function, with Lite-C, you need to pass the first element of a vector and the next 2 elements will be taken automatically. The same goes for entity skills (ex:
vec_set(my.skill1, vector(1, 2, 3));
to set both skill1, skill2, and skill3), and entity rotation (you only need to pass the entity pan as a vector parameter of a function). Hope you understand. Best regards. Yeah... Thanks.. But Then that code you sent me should work? But It don't!  And is that skill1-3 a variable or something else? 
|
|
|
|