It's never too late to change a long code to a short.
I'll try it and get back to you. Thanks.
Off this topic though, I wonder if you can help me with this problem I am having.
//Function for finding polygons
function checkSolid(ENTITY* myObject)
{
set(my,PASSABLE);
pos_result2 = c_trace(vector(myObject.x,myObject.y,myObject.z),
vector(myObject.x,myObject.y,myObject.z-600), USE_POLYGON);
if (pos_result2 > 0)
{
// Set the entity's physical properties.
/* Registers / unregisters an entity with the physics system.*/
phent_settype(myObject,PH_RIGID,PH_BOX);
/* (In Kilograms) The smallest mass you can specify is 0.001.
The conversion factor from pounds (on Earth) to kilograms is 1 lb. =
0.45 kg.*/
phent_setmass(myObject,5,PH_BOX);
/* (For collisions) friction is what makes objects stick to each other,
when moved sideways. Whenever possible you should set friction to 0,
as this speeds up the calcuations and prevents instability.*/
phent_setfriction(myObject,0);
/* Bounce */
phent_setelasticity(myObject,15,100);
/* Apply force and torque. */
phent_setdamping(myObject,0,0);
/* Gravity */
ph_setgravity(vector(0,0,-200));
}
else
{
//If it misses
ent_remove(myObject);
replot1 = 1; //recreate it
}
}
I created an object which uses this function. It works fine. I tested it over and over
to make sure the object finds a solid surface below it, and it does every time. My
problem is, I created another object which I want to do the same. However, although I
used another function, with the same code (entity name changed), the other object falls
and misses the solid surface repeatedly.
Why does it fall if it uses c_trace to detect if there is a solid surface beneath it,
and finds none? It's not supposed to fall until it detects a solid surface. I don't
understand it. I tried many ways to correct this and I am getting nowhere.
Would you be able to explain why this is not working?