|
Post by Lukas W on Aug 19, 2005 21:47:25 GMT 1
i have two questions: 1) im my game i want explosions i have a pistol right, so i shoot at a cube. the cube moves. i have added a life variable to the cube. when cube is hit by bullet, life decreases. when life is smaller or equals zero the cube will die. when the cube dies it will explode into small pieces. like a cube is built out of 6 faces. when life reaches 0 the cube is deleted and 6 planes/boxes are created. now i want these faces to explode, instead of just falling lifeless to the ground. how would i do that? 2) how would i make a human model move? edit, wait.. is it similar to the way the player moves? like instead of: if "w"=inkey$() then i can use if ai.direction = forward then? i just though of that right now.. i have not tested it yet so maybe i wont need help with this question..
|
|
|
Post by kjelle69 on Aug 20, 2005 10:29:39 GMT 1
|
|
|
Post by Lukas W on Aug 20, 2005 17:03:24 GMT 1
thanks ill have a look at that thread:)
|
|
|
Post by Lukas W on Aug 20, 2005 20:51:16 GMT 1
you know what.. its impossible this is what im thinking: use raycast to fire, then where the raycast hit will be the center of the explosion. so, i know the center. now what? i need to check if there are objects inside the explosion radius. we do it like this: x#, y#, z# are the position of the raycast ending aka the rocket position. !!not actual code!! for x = 1 to TotalObjectsInGame if object.type = moveable
distanceToRocket = SQRT( (x#-objposx)^2+(y#-objposy)^2+(z#-objposz)^2 )
if distanceToRocket < ExplosionPower
object( x ).inZone = True
endif endif
next x
ok we know which objects are inside the Damage Radius now what? we need to move these objects. for x = 1 to totalObjectsInGame
if Object(x).InZone = True
[b]WHAT IS THE COMMAND TO GET 'dbpro object' TO 'newton body'?[/b] NDB_BodyGetPosition bodyToAffect NDB_SetVector 2, pExplosionPower#*dist#, pExplosionPower#*dist#, pExplosionPower#*dist# NDB_BodyAddForceGlobal bodyToAffect NDB_NewtonWorldUnfreezeBody bodyToAffect
endif
next x
dist# is the value we got from Raycasting. dist is always smaller than 1.0 so we need to calculate in order to divide. and we get the Force and add it to the Body which is inside the Rocket Radius. However, i have not managed to write any of this.. its just theory as of now but what do you think?
|
|
|
Post by kjelle69 on Aug 21, 2005 0:46:31 GMT 1
The theory looks nice, you could do it all in Newton without using DBPro position code. Let the force be global from point x,y,z (Missile hitpoint) with size (force) equal to the power of the distance to the object . (Closer = higher force).
|
|
|
Post by Lukas W on Aug 21, 2005 2:40:34 GMT 1
hmm, so i noticed:) you know what? this actually works thanks alot! did you know how to do it from the beginning or did you just guess?? im impressed
|
|
|
Post by kjelle69 on Aug 21, 2005 10:58:03 GMT 1
I knew. You can do almost anything with Newton !
|
|
|
Post by Lukas W on Aug 21, 2005 15:06:20 GMT 1
that is cool hmm, now i have another problem for x = 1 to totalEnemies obj = 2000+x load object "models\zombieModel.x", obj scale object obj, 1.5, 1.5, 1.5 position object obj, -20, 50, 60 yrotate object obj, rnd(359)
Col = NDB_NewtonCreateConvexHull( obj ) Body = NDB_NewtonCreateBody(Col) Zombie(x).Body = Body
sx# = object size x(obj) : sy# = object size y(obj) : sz# = object size z(obj) NDB_CalculateMIBoxSolid 12.0, sx#, sy#, sz# NDB_NewtonBodySetMassMatrix Body, 12.0
NDB_NewtonReleaseCollision Col
NDB_BuildMatrix 0.0, object angle y( obj ), 0.0, object position x(obj), object position y(obj), object position z(obj) NDB_NewtonBodySetMatrix Body
NDB_NewtonBodySetDestructorCallback Body NDB_BodySetDBProData Body, obj
Zombie(x).ObjId = obj Entity( obj ).ZombieId = x
NDB_BodySetGravity Body, 1 next x that is the code i have. i am adding a zombie to the game. i add convexhull collision to the object, but it goes straight through the floor anyway. i dont get it.. what do you thikn is wrong?
|
|
|
Post by kjelle69 on Aug 22, 2005 16:22:15 GMT 1
It seems that you scale the .x model to 1.5 percent of its starting size accoring to the manual: scale object obj, 1.5, 1.5, 1.5 SCALE OBJECT This command will scale the specified 3D object to stretch or shrink in all three dimensions, using percentage scale values. The object number should be specified using an integer value and the scale specified using real values. SYNTAX SCALE OBJECT Object Number, XSize, YSize, ZSize If that is so, then your Newton collision object is 100 times bigger. Try to debug your code so that you see the newton world. See the demos to learn how to debug, it's very powerful !
|
|
|
Post by Lukas W on Aug 22, 2005 16:57:38 GMT 1
oh, so you mean like if my original object is size 100,100,100 then the newton body will be 100,100,100. but if i scale my object 1.5,1.5,1.5 then the body will still be at 100,100,100?? thanks ill look into the debug thing. but now i have to eat
|
|
|
Post by Lukas W on Aug 23, 2005 9:34:31 GMT 1
you are right, the newton object is alot bigger than the dbpro object. edit, thanks alot (again). i found that the NDB_NewtonCreateConvexHullWithScale command was partically usefull for this
|
|
|
Post by kjelle69 on Aug 23, 2005 20:18:54 GMT 1
Yeaah ! That's the one to use if you want to scale convex hulls. !! :-)
|
|
|
Post by Lukas W on Aug 24, 2005 19:39:22 GMT 1
hmm, i have yet another problem i got the zombie walking around allright, minding his own bussiness, but when i collide with it, it is thrown out in space for no reason at all i have no clue what might be causing this.. however ill continue on searching for the solution but i thought maybe you know what is going on
|
|
|
Post by kjelle69 on Aug 24, 2005 20:28:08 GMT 1
Sounds Hilarious ! We want screenshots :-)
|
|
|
Post by Lukas W on Aug 25, 2005 12:54:22 GMT 1
...its only happening when the fps drops too much
|
|