how to attach sprite entity to model?

Posted By: ncc1701d

how to attach sprite entity to model? - 02/18/10 07:53

can someone show me how to attach a sprite entity to the model?

my attempt was doing it like a camera but this may be wrong.
I think using vectors is wrong but Iam not sure of the alternative.
This crashes in attach_entity()

here are the key parts below
thanks

////////////////////////////
void attach_entity();


box = ent_create ("boat.mdl", vector(-400, 0, 570), attach_entity); //

ent_explo = ent_create("flash+3.tga", vector(-200, 0, 0), lightcolor);



void attach_entity()
{
while(1)
{
vec_set(ent_explo.x,my.x);
vec_set(ent_explo.y,my.y);
vec_set(ent_explo.z,my.z);
wait(1);
}
}
Posted By: Matt_Coles

Re: how to attach sprite entity to model? - 02/18/10 08:12

haven't tested it, but it should be something similar to this:


var timetocallsprite;

function yourscript()
{
while(1)
{
if (timetocallsprite == 1)
{
ent_create ("yourpic.tga", vector(my.x,my.y,my.z), youraction);
}
wait(1);
}
}

Posted By: badapple

Re: how to attach sprite entity to model? - 02/18/10 08:12

nevermind matt got ya at the same time
Posted By: Matt_Coles

Re: how to attach sprite entity to model? - 02/18/10 09:13

I have to say awesome team tag work there on our behalfs badapple! grin
Posted By: ncc1701d

Re: how to attach sprite entity to model? - 02/20/10 00:57

what is wrong with how I applyed what said?
I just took the sample moving ball from the the tutorial.
You can sub my tga with anything if you want to test it out.
I was trying to attach the entity to the ball.



///////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
#include <atypes.h>
///////////////////////////////////////////////////////////////

VECTOR ball_force;
ENTITY* ball;
var timetocallsprite;
BMAP* bmp_explo = "thrpink3+3.tga";
ENTITY* ent_explo;


function yourscript()
{
while(1)
{
if (timetocallsprite == 1)
{
ent_create("thpink+3.tga", vector(my.x, my.y, my.z), NULL);
ent_explo.roll = 0.001;
}
wait(1);
}
}


function main()
{
level_load("roller.wmb");
ball = ent_create ("ball.mdl", vector(-400, 0, 100), yourscript);
ph_setgravity (vector(0, 0, -386));
phent_settype (ball, PH_RIGID, PH_SPHERE);
phent_setmass (ball, 3, PH_SPHERE);
phent_setfriction (ball, 80);
phent_setdamping (ball, 40, 40);
phent_setelasticity (ball, 50, 20);
while (1)
{
ball_force.x = 150 * time_step * (key_cur - key_cul);
ball_force.y = 150 * time_step * (key_cuu - key_cud);
ball_force.z = 0; //
phent_addtorqueglobal (ball, ball_force);
camera.x = ball.x - 300;
camera.y = ball.y;
camera.z = 1000;
camera.tilt = -60;
wait (1);
}
}
© 2024 lite-C Forums