Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, degenerate_762, AndrewAMD, ozgur), 774 guests, and 0 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
Vector Problem #410872
11/10/12 12:45
11/10/12 12:45
Joined: Nov 2011
Posts: 29
G
GreenDeveloper Offline OP
Newbie
GreenDeveloper  Offline OP
Newbie
G

Joined: Nov 2011
Posts: 29
hello everybody;
i have a small probmelem.

i want always do that


but when i turn player angle, its have a small problem





Code:
function particle()
{
	vec_add(par_vec.x, player.x);
	vec_set(par_vec.x, vector(0, 0, 0));
	vec_rotate(par_vec.x, player.pan);
	par_vec.x = player.x - 10 * cos(player.pan);
 	par_vec.y = player.y - 10 * sin(player.pan);
 	par_vec.z = player.z + 10;
 	
	cikarma = 1;	
	while(key_space)
	{
		if(cikarma==1)
		{
			effect(gas_function, 20, par_vec.x, nullvector);
			media_play("fart.wav", NULL, 100);
		}
		wait(1);
	
	}	
}


Last edited by GreenDeveloper; 11/10/12 12:47.

"Actually we are all Guybrush.." GreenDeveloper
Re: Vector Problem [Re: GreenDeveloper] #410873
11/10/12 12:57
11/10/12 12:57
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
first vec_set, then vec_rotate and then finally vec_add wink
Just do:
Code:
vec_set(par_vec.x, vector(10, 0, 0));
vec_rotate(par_vec.x, player.pan);
vec_add(par_vec.x, player.x);


Re: Vector Problem [Re: Ch40zzC0d3r] #410874
11/10/12 13:00
11/10/12 13:00
Joined: Nov 2011
Posts: 29
G
GreenDeveloper Offline OP
Newbie
GreenDeveloper  Offline OP
Newbie
G

Joined: Nov 2011
Posts: 29
it doesnt work. frown


"Actually we are all Guybrush.." GreenDeveloper
Re: Vector Problem [Re: GreenDeveloper] #410876
11/10/12 13:08
11/10/12 13:08
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
sorry, but does this make any sense?
Code:
vec_add(par_vec.x, player.x);
vec_set(par_vec.x, vector(0, 0, 0));
vec_rotate(par_vec.x, player.pan);



...and can you please post the particle-function, too?
I think the 'problem' should be in there.

EDIT: or try this (not tested):
Code:
function particle()
{
	VECTOR particle_velocity;
 	
 	var speed = 5; // particle speed - this needs to be adjusted!
 	
	cikarma = 1;	
	while(key_space)
	{
		if(cikarma==1)
		{
			vec_set(particle_velocity, vector(-speed, 0, 0);
			vec_rotate(particle_velocity, player.pan);
			
			effect(gas_function, 20, player.x, particle_velocity);
			media_play("fart.wav", NULL, 100);
		}
		wait(1);
	}	
}


Last edited by Kartoffel; 11/10/12 13:12.

POTATO-MAN saves the day! - Random
Re: Vector Problem #410879
11/10/12 13:25
11/10/12 13:25
Joined: Nov 2011
Posts: 29
G
GreenDeveloper Offline OP
Newbie
GreenDeveloper  Offline OP
Newbie
G

Joined: Nov 2011
Posts: 29
Originally Posted By: Kartoffel
sorry, but does this make any sense?
Code:
vec_add(par_vec.x, player.x);
vec_set(par_vec.x, vector(0, 0, 0));
vec_rotate(par_vec.x, player.pan);



...and can you please post the particle-function, too?
I think the 'problem' should be in there.

EDIT: or try this (not tested):
Code:
function particle()
{
	VECTOR particle_velocity;
 	
 	var speed = 5; // particle speed - this needs to be adjusted!
 	
	cikarma = 1;	
	while(key_space)
	{
		if(cikarma==1)
		{
			vec_set(particle_velocity, vector(-speed, 0, 0);
			vec_rotate(particle_velocity, player.pan);
			
			effect(gas_function, 20, player.x, particle_velocity);
			media_play("fart.wav", NULL, 100);
		}
		wait(1);
	}	
}



sorry, but does this make any sense? - unfortunately no.

EDIT: or try this - it gives the same result

...and can you please post the particle-function, too? - here;

Code:
function event_gas(PARTICLE *p)
{
	p.red=5;
	p.blue=5;
	p.green=500;
}

function gas_function(PARTICLE *p)
{
	p.vel_y +=random(50);
	p.vel_x -=random(90);
	p.vel_z +=random(8)+2;
	p.red=206;
	p.blue=22;
	p.green=32;
	p.lifespan=5;
	p.size=random(20) + 5;
	p.bmap=greenparticle;
	p.event=event_gas;
	max_particles=30;
	set(p, MOVE | BRIGHT | TRANSLUCENT);
}


Last edited by GreenDeveloper; 11/10/12 13:27.

"Actually we are all Guybrush.." GreenDeveloper
Re: Vector Problem [Re: GreenDeveloper] #410881
11/10/12 13:27
11/10/12 13:27
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
-.-
p.vel_y +=random(50);
p.vel_x -=random(90);
p.vel_z +=random(8)+2;

Use my code instead of this + add some randoms

Re: Vector Problem [Re: Ch40zzC0d3r] #410882
11/10/12 14:01
11/10/12 14:01
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Ch40zzC0d3e is right.
you way of randomizing the particle's velocity is the problem.

It has to be applied before rotating the velocity vector:
Code:
function particle()
{
	VECTOR particle_velocity;
 	
 	var speed = 5; // particle speed - this needs to be adjusted!
 	var r_a = 75; // random angle

	cikarma = 1;	
	while(key_space)
	{
		if(cikarma==1)
		{
			vec_set(particle_velocity, vector(-random(speed), 0, 0); // randomize velocity
			vec_rotate(particle_velocity, vector(player.pan + random(r_a / 2) - r_a, player.tilt + random(r_a / 2) - r_a, 0); // randomize angle
			
			effect(gas_function, 20, player.x, particle_velocity);
			media_play("fart.wav", NULL, 100);
		}
		wait(1);
	}	
}


this should work if you remove the random velocity from your particle function

Last edited by Kartoffel; 11/10/12 14:10.

POTATO-MAN saves the day! - Random

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