Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 744 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
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 Offline OP

Expert
Realspawn  Offline 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 laugh


thank you for your time\

Code:
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.

Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
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
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Facing the camera:
Code:
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:
Code:
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: Ch40zzC0d3r] #460683
07/10/16 17:55
07/10/16 17:55
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline OP

Expert
Realspawn  Offline OP

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
thx not sure how to make it work. With what i have the bullet sprites go the right way and follow the player till hit. But it looks like the pan is facing always in the direction of the player even with you script added.


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: Keep sprite faced at the camera. [Re: Realspawn] #460685
07/10/16 18:12
07/10/16 18:12

M
Malice
Unregistered
Malice
Unregistered
M



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
Quote:
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: ] #460687
07/10/16 18:14
07/10/16 18:14
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
If you know exactly where it has to go you can use absolute movement in c_move, or you do what I said and set the angles before calling c_move and then change them back to face the camera.

Re: Keep sprite faced at the camera. [Re: Ch40zzC0d3r] #460688
07/10/16 18:27
07/10/16 18:27

M
Malice
Unregistered
Malice
Unregistered
M



-- Ch40zzC0d3r's solution is perfectly valid and working..

Re: Keep sprite faced at the camera. [Re: ] #460689
07/10/16 18:34
07/10/16 18:34
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline OP

Expert
Realspawn  Offline OP

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
have to go to work dive into this stuff tomorrow i am very close laugh


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
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 Offline
Member
NeutronBlue  Offline
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

M
Malice
Unregistered
Malice
Unregistered
M



ORIENTED, FACING replaced as of A6

http://www.conitec.net/beta/aAnhang_Syntax.htm

Re: Keep sprite faced at the camera. [Re: ] #460722
07/11/16 23:19
07/11/16 23:19

M
Malice
Unregistered
Malice
Unregistered
M



if vSpeed is your rate. Rel movement can be converted to abs movement as fallows.
Code:
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.
Page 1 of 2 1 2

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