Posted By: oliver2s
crash with ent_playloop and pXent_getspeed - 10/10/13 08:43
I get an engine when I using ent_playsound in combination with the "pXent_getspeed" function from "car.c" in gamestudio folder ("\include\"):
What sound file you are using doesn't matter. It crashes with wav and ogg. The file is also not broken, I've tried many different sound files, even some files vom gamestudio folder.
What sound file you are using doesn't matter. It crashes with wav and ogg. The file is also not broken, I've tried many different sound files, even some files vom gamestudio folder.
Code:
#include <acknex.h> #include <ackphysx.h> SOUND* snd_test="test.wav"; var snd_hndl=0; //this function is from /include/car.c in gamestudio folder var pXent_getspeed(ENTITY* ent) { VECTOR vSpeed,vDir; pXent_getvelocity(ent,vSpeed,NULL); vec_for_angle(vDir,ent.pan); // speed in km/h, assume 40 quants = 1 m var speed = vec_dot(vDir,vSpeed) * (60.*60.)/(40.*1000.); if (abs(speed) < 1) return 0; else return speed; } void main() { physX_open(); level_load(NULL); ENTITY* ent_tmp=ent_create(CUBE_MDL,nullvector,NULL); pXent_settype(ent_tmp,PH_RIGID,PH_BOX); wait(-3); while(1) { pXent_getspeed(ent_tmp); if(!snd_playing(snd_hndl)) { snd_hndl=ent_playloop(ent_tmp,snd_test,100); } wait(1); } }