1 registered members (AndrewAMD),
911
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Keep sprite faced at the camera.
[Re: ]
#460746
07/12/16 15:23
07/12/16 15:23
|
Joined: Jul 2001
Posts: 4,801 netherlands
Realspawn
OP
Expert
|
OP
Expert
Joined: Jul 2001
Posts: 4,801
netherlands
|
The solution of Ch40zzC0d3r works like as charm so for others that encounter this programm here is the script that i use now and works.
action e_bullet()
{
set(my,PASSABLE | BRIGHT );
my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY | ENABLE_IMPACT);
my.event = ice_hit;
wait(1);
c_setminmax(me);
my.lightrange = 100;
my.ambient =255;
VECTOR temp;//declare temp vector
while(!surfer1){wait(1);
}
while(1)
{
if(vec_dist(my.x,enemy.x) >120){
reset(my,PASSABLE);
}
//Set angle towards player
vec_set(temp, surfer1.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan , temp);
//Will use relative movement facing the player
c_move(my, vector(5* time_step, 0, 0), nullvector, IGNORE_SPRITES | IGNORE_PASSABLE);
//Change angle now so it faces camera
vec_set(temp, camera.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
wait(1); //The angle will stay this way until the next frame loads (aka visible part of the frame)
}
}
Last edited by Realspawn; 07/12/16 21:05.
|
|
|
Re: Keep sprite faced at the camera.
[Re: rayp]
#460753
07/12/16 22:04
07/12/16 22:04
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
Remove the NULL from c_move it makes no sense for me btw. edit: And you forgot to wait one frame with the c_setminmax instruction. edit2: Not sure but isnt there one wait(1) too much? If not i would recomment to use wait(2) instead Absolute movement would be better here, but iam too stupid to calculate the vectors The absolute movement is what I said earlier, but I knew you want an easy solution so I didnt post that code. In the end its just as simple as this:
VECTOR vAbs;
vAbs.x = speed * sinv(DegToRad(angDir.pan));
vAbs.y = speed * cosv(DegToRad(angDir.pan));
vAbs.z = speed * sinv(-DegToRad(angDir.tilt));
Not sure with the signs though
Last edited by Ch40zzC0d3r; 07/12/16 22:18.
|
|
|
Re: Keep sprite faced at the camera.
[Re: Ch40zzC0d3r]
#460759
07/13/16 11:25
07/13/16 11:25
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
I don't see why relative movement should be bad but you can also take a relative movement vector and use vec_rotate(&vMove, &ent->pan); Then you can use it as an absolute vector.
I'm pretty sure that's what the function does with relative movement vectors anyway.
POTATO-MAN saves the day! - Random
|
|
|
|