0 registered members (),
744
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Keep sprite faced at the camera.
#460681
07/10/16 17:20
07/10/16 17:20
|
Joined: Jul 2001
Posts: 4,801 netherlands
Realspawn
OP
Expert
|
OP
Expert
Joined: Jul 2001
Posts: 4,801
netherlands
|
I use this sprite for bullet and it moves as it should to the player how ever it turns. How can i make the sprite move this way but keep facing the camera. Working on a new tutorial and its the last piece of the puzzle needed thank you for your time\
action e_bullet()
{
set(my,BRIGHT);
my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY | ENABLE_IMPACT);
my.event = ice_hit;
c_setminmax(me);
VECTOR temp;
while(!surfer1){wait(1);
}
while(1)
{
c_move(my, vector(-5* time_step, 0, 0), nullvector, NULL | IGNORE_SPRITES | IGNORE_PASSABLE);
vec_set(temp, surfer1.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan , temp);
wait(1);
}
}
Last edited by Realspawn; 07/10/16 17:21.
|
|
|
Re: Keep sprite faced at the camera.
[Re: Realspawn]
#460682
07/10/16 17:31
07/10/16 17:31
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
Facing the camera:
VECTOR tmp;
vec_set(tmp, camera.x);
vec_sub(tmp, my.x);
vec_to_angle(my.pan, tmp);
Save the angle you need somewhere else like in a skill or the like:
Set angle to the c_move direction
c_move()
face player
Last edited by Ch40zzC0d3r; 07/10/16 17:34.
|
|
|
Re: Keep sprite faced at the camera.
[Re: Realspawn]
#460685
07/10/16 18:12
07/10/16 18:12
|
Malice
Unregistered
|
Malice
Unregistered
|
Set it's pan always to 0 Then using abs movement not rel movement to chase the player. I'll post a bit of code later if no one else does. Manual Angles have a special meaning with sprites. If all angles are at zero, the sprite will stand upright and horizontally face the camera. If its pan or tilt angle is nonzero, the sprite is oriented in world space according to its angles. If pan and tilt both are 0, but the roll angle is nonzero, the sprite is always perpendicular to the camera. This is useful for spherical objects, like fireballs or explosions. For an angle to be nonzero it's sufficient to set it at a small amount, like 0.01. http://www.conitec.net/beta/aentity-pan.htm
Last edited by Malice; 07/10/16 18:17.
|
|
|
Re: Keep sprite faced at the camera.
[Re: Ch40zzC0d3r]
#460688
07/10/16 18:27
07/10/16 18:27
|
Malice
Unregistered
|
Malice
Unregistered
|
-- Ch40zzC0d3r's solution is perfectly valid and working..
|
|
|
Re: Keep sprite faced at the camera.
[Re: Realspawn]
#460719
07/11/16 22:08
07/11/16 22:08
|
Joined: Aug 2003
Posts: 180 Reactor Core
NeutronBlue
Member
|
Member
Joined: Aug 2003
Posts: 180
Reactor Core
|
Not sure if this works for moving sprites (as an 'entity') - but what about the "Oriented" flag for sprites??
Dreaming ain't Doing..! <sigh> Darn semicolons - I always manage to miss at least 1..!
|
|
|
Re: Keep sprite faced at the camera.
[Re: NeutronBlue]
#460720
07/11/16 23:09
07/11/16 23:09
|
Malice
Unregistered
|
Malice
Unregistered
|
|
|
|
Re: Keep sprite faced at the camera.
[Re: ]
#460722
07/11/16 23:19
07/11/16 23:19
|
Malice
Unregistered
|
Malice
Unregistered
|
if vSpeed is your rate. Rel movement can be converted to abs movement as fallows.
var vSpeed = 5;
VECTOR vec_move;
while()...
vec_set(vec_move,vector(key_w-key_s,key_a-key_d,0));
vec_rotate(vec_move,my.pan);
c_move(my,nullvector,vec_scale(vec_move,vSpeed*time_step),FLAGS);
...
// using abs movement your pan/tilt/roll can stay 0//
--Edit Thou vec_normalize maybe a better choice. http://www.conitec.net/beta/avec_normalize.htm However -Ch40zzC0d3r solution is perfectly valid also. Take Care --
Last edited by Malice; 07/11/16 23:30.
|
|
|
|