1 registered members (AndrewAMD),
1,534
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
How to combine x,y,z,pan,tilt,roll in one element ?
#341370
09/15/10 15:19
09/15/10 15:19
|
Joined: Nov 2003
Posts: 433 The Netherlands
Toon
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2003
Posts: 433
The Netherlands
|
How can i turn my canon to the you position? I have a simplified version of my code below, please asume the you pointer is set.. What i basicly want to know is how to combine a vector and angle in one element like 'before' with wdl
function act_canon()
{
var temp;
VECTOR testvec;
while(1)
{
vec_set(temp,you.x);
vec_sub(temp,testvec.x);
vec_to_angle(testvec.pan,temp);
ent_bonerotate(my,"canon",testvec.pan);
wait(1);
}
}
|
|
|
Re: How to combine x,y,z,pan,tilt,roll in one element ?
[Re: Toon]
#341371
09/15/10 16:04
09/15/10 16:04
|
Joined: Jan 2004
Posts: 3,023 The Netherlands
Helghast
Expert
|
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
function act_canon()
{
VECTOR temp;
VECTOR testvec;
while(1)
{
vec_set(temp.x, you.x);
vec_sub(temp.x, testvec.x);
vec_to_angle(testvec.x, temp.x);
ent_bonerotate(my, "canon", testvec.x);
wait(1);
}
}
untested, but I believe this works... regards,
|
|
|
Re: How to combine x,y,z,pan,tilt,roll in one element ?
[Re: Toon]
#341372
09/15/10 16:05
09/15/10 16:05
|
Joined: Dec 2008
Posts: 271
Saturnus
Member
|
Member
Joined: Dec 2008
Posts: 271
|
Try this:
typedef struct
{
var x, y, z;
var pan, tilt, roll;
} MY_VECTOR;
and just replace "VECTOR testvec" with "MY_VECTOR testvec".
|
|
|
Re: How to combine x,y,z,pan,tilt,roll in one element ?
[Re: Saturnus]
#341373
09/15/10 16:15
09/15/10 16:15
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
i think a struct is a bad idea it wont work, because the engine doesn't use pan tilt roll or x y z, it only uses the memory allocated by the size of three vars! you can also write this:
function act_canon()
{
VECTOR temp;
VECTOR testvec;
while(1)
{
vec_set(temp.x, you.x);
vec_sub(temp.x, testvec.x);
vec_to_angle(testvec.x, temp.x);
ent_bonerotate(my, "canon", testvec);
wait(1);
}
}
you only need the .x if you use any sort of struct like an entity or view! ao the code with the defined struct won't work!
|
|
|
Re: How to combine x,y,z,pan,tilt,roll in one element ?
[Re: MasterQ32]
#341377
09/15/10 16:56
09/15/10 16:56
|
Joined: Nov 2003
Posts: 433 The Netherlands
Toon
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2003
Posts: 433
The Netherlands
|
Thanks for reply but the canon keeps spinning real fast, i tried it with the function below to test and see what the targets where... none of the targets are moving so the canon should now face the closest target but it just spins like >
action act_boat()
{
VECTOR temp;
VECTOR testvec;
while(1)
{
if(!you)
{
c_scan(my.x,my.pan,vector(360,360,10000),SCAN_ENTS | SCAN_LIMIT | IGNORE_ME | IGNORE_FLAG2);
beep();
wait(-1);
}
else
{
if(key_del == 1)
{
beep();
ent_remove(you);
}
else
{
vec_set(temp.x, you.x);
vec_sub(temp.x, testvec.x);
vec_to_angle(testvec.x, temp.x);
ent_bonerotate(my, "canon", testvec);
}
}
wait(1);
}
}
|
|
|
Re: How to combine x,y,z,pan,tilt,roll in one element ?
[Re: Toon]
#341395
09/15/10 20:36
09/15/10 20:36
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
have a look at ent_bonereset(), each bone rotate is adding to it's previous rotation
|
|
|
|