0 registered members (),
900
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Vector Problem
#410872
11/10/12 12:45
11/10/12 12:45
|
Joined: Nov 2011
Posts: 29
GreenDeveloper
OP
Newbie
|
OP
Newbie
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
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]
#410876
11/10/12 13:08
11/10/12 13:08
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
sorry, but does this make any sense?
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):
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
GreenDeveloper
OP
Newbie
|
OP
Newbie
Joined: Nov 2011
Posts: 29
|
sorry, but does this make any sense?
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):
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;
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: Ch40zzC0d3r]
#410882
11/10/12 14:01
11/10/12 14:01
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
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:
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
|
|
|
|