I know i started this in the other topic but felt it best to start a new topic as my problems wandered so far from the old topic description that its possible people wouldnt bothere reading if it didnt interest them...
Basically im learning this Lite-C malarky and have become quite stuck:
function new_box() { box my_box; my_box.model = "cube.x"; my_box.model.x = -400; my_box.model.y = 0; my_box.model.tilt = 145; my_box.model.z = 2800; phent_settype (my_box.model, PH_RIGID, PH_BOX); // set the physics entity type phent_setmass (my_box.model, 3, PH_BOX); // and its mass phent_setfriction (my_box.model, 80); // set the friction phent_setdamping (my_box.model, 40, 40); // set the damping phent_setelasticity (my_box.model, 50, 20); // set the elasticity }
the two models are cubes and the program is supposed to create a new box every time the E key is pressed. However running the code above, lite-c simply gives the error:
"Malfuntion w1600 Entity not a physics object in main" OK - CANCEL
What does this mean? :s
I am a noob to this... Blitz3D is where i am best at!
Re: arrays of object.... continued
[Re: CdeathJD]
#226470 09/09/0822:4409/09/0822:44
ph_setgravity (vector(0, 0, -886)); // set the gravity
while (1) { // CONTROLS mouse_pos.x = mouse_cursor.x; mouse_pos.y = mouse_cursor.y; camera.pan -= mouse_force.x * 2; camera.tilt += mouse_force.y * 2; if (key_cuu) camera.x -= 252 * time_step; if (key_cud) camera.x += 252 * time_step; if (key_cul) camera.y += 252 * time_step; if (key_cur) camera.y -= 252 * time_step; if (key_enter) new_box; //on_e = wait(1); } } ================================================================================ at the "key_enter" part it all goes wrong and gives me that useless "sytax error" again, even though the function works using the commented out "on_e". But i want to make it happen whilst a key is pressed down.... why isn't it working? argh!
I am a noob to this... Blitz3D is where i am best at!
Re: arrays of object.... continued
[Re: CdeathJD]
#226541 09/10/0809:2809/10/0809:28
Simple enough. When calling a function from code, as opposed to an on_key command, you need to specify what parameters are being passed to the function, even if there isnt any.
To summarise, change the line if (key_enter) new_box; to be if (key_enter) new_box();
and it'll fix the syntax error. I havent looked any deeper than that.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
Re: arrays of object.... continued
[Re: EvilSOB]
#226566 09/10/0811:1709/10/0811:17
thats rather crazy, in that sometimes you dont have to add "()" on and sometimes you do... personally i prefer to do so all the time! Regardless, the code works and works well, besides a few strange physics errors which i have found:
1) for some reason there appears to be an invisable (and undeclared) box around an area of the screen.
2) The physics seems to crash when i go a bit mental with the ENTER key. I think this may be because when the stream of cube reaches the mystery bounding box, a collision is forced all the way down the line of objects, which stops the most newly created object from moving at all, the engine then tries to create a new physics box next frame in the exact same space, and thus doesnt really know how to solve the collisions and thus throws a benny!
Would i be right in all that?
3) Also how would i go about altering these entities. In blitz there would be something like an "for b.box = each box" command. Ideally im trying to add a "life" property which decreases to zero and then the entity is removed, just to get the hang of acessing individual struct entries properties.
Last edited by CdeathJD; 09/10/0816:18. Reason: Added q3!
I am a noob to this... Blitz3D is where i am best at!
Re: arrays of object.... continued
[Re: CdeathJD]
#226647 09/10/0817:0309/10/0817:03
I'll answer as best I can, but Im no physics guru.
1) I have seen in other posts thats there is some form of virtual bounding box in lite-c to minimise resource requirements. I think your blocks may be hitting that. It seems this 'box' is based on object placement, but not size. So your 'plain' may be sticking out the sides without forcing it to expand. Put the following code into main before the loop and see if it helps. It did weird things to mine but I may be using badly sized models.
2) I think you are half right about your phisics going splat, but not cause the this mysterious box. I think its just too many boxes overlapping each other causing it to go schitzo.
3) Complex question here, but I would suggest looking at some "particle" tutorials because thats exactly how they are forced behave often, and they be able to explain better than I best way to do this. (Each entity will take care of itself)
Best of luck
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
Re: arrays of object.... continued
[Re: EvilSOB]
#226824 09/11/0814:3509/11/0814:35
Go to the website http://au.conitec.net/ amd look under tutorials link, handy site. Its also accessable from the "resources" link at the footer of this forums pages.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial