Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (M_D), 1,430 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
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 Offline OP

Expert
Realspawn  Offline OP

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
The solution of Ch40zzC0d3r works like as charm laugh

so for others that encounter this programm here is the script that i use now and works.


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

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

Creativity starts in the brain
Re: Keep sprite faced at the camera. [Re: Realspawn] #460748
07/12/16 19:33
07/12/16 19:33
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
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 grin
Absolute movement would be better here, but iam too stupid to calculate the vectors grin

Last edited by rayp; 07/12/16 19:52.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Keep sprite faced at the camera. [Re: rayp] #460751
07/12/16 21:06
07/12/16 21:06
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline OP

Expert
Realspawn  Offline OP

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
if your to stupid hahah what does it make me grin

changed it in the post laugh


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

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

Joined: Oct 2011
Posts: 1,082
Germany
Originally Posted By: rayp
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 grin
Absolute movement would be better here, but iam too stupid to calculate the vectors grin


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:
Code:
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 Offline
Expert
Kartoffel  Offline
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
Re: Keep sprite faced at the camera. [Re: Kartoffel] #460760
07/13/16 15:05
07/13/16 15:05

M
Malice
Unregistered
Malice
Unregistered
M



By changing the pan to use rel movement to face the target you void the engines automatic 'always face the camera' behavior, is all.

By the way - this is the same answer I've already posted.

http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=460722#Post460722

Last edited by Malice; 07/13/16 15:13.
Page 2 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