How to make a destroyable but immobile building ? (Static, rigid body, don't work)

Hi,

I want to make a hangar that spits out tanks. It should also be destroyable.

Now, I have a problem what kind of object to make it =

  1. Static = it will not be destroyable, because static does not work with collision.
    So the projectile is not detected (I use slow bullets, not rays)

  2. Everythin other than static (e.g. rigid body), the tanks push it around in a very funny manner.

How to make it immobile AND collision aware ? How do the pros do it ?

Thanks in advance

  1. Static = it will not be destroyable, because static does not work with collision.
    So the projectile is not detected (I use slow bullets, not rays)

i suggest static, static has the best collision detection.

Make a building how you like it. keep it static.
at the point where it needs to spit out tanks, place an empty, let that empty spawn the tanks.

deastroying is as easy as changing meshes and spawn some flying rocks.

By collision you mean that other objects stop on it ?

Yes, sure.

But I want to use the Collision Sensor, to sense the contact with the player’s cannon ball.
AFAIK, the Collision sensor does not work with Static objects.

The collision sensor does work with static objects, just make sure you have the ‘actor’ checkbox ticked (in the physics settings)

If both objects are Static actors it does not work for me.

I have a tank that shoots missiles --> Static actors.

But I am forced to make the enemy tanks Dynamic, or Rigid Bodies, or whatever,
because if the enemy tanks are also Static actors, then nothing happens when they come
in contact wit the missile. Just changing them back to Dynamic, makes them work again
(no other settings changed).

If you know the answer to this problem, please advise, because it is quite important for my project.

Dimitris

tanks, bullets,enemies should all be dynamic
walls, floors should be static

Heres an easy way, one of many.

leave the hangar static give it a collision sensor looking for property “bullet” or whatever. Doesn’t need to be an actor.

On the hanger - Sensor Collision “bullet” (without quotes)-----and-----add object actuator(s) and an end object actuator (so hanger ends, and debris is spawned)

Make your missle dynamic, give it a property called “bullet” it don’t need to be an actor. and shoot it from an empty.

On the Empty - sensor (whatever)---------and----------add object missle lin velocity 50 or whatever

Make your broken hanger, debris pile, rocks, whatever and put them on an inactive layer. make them dynamic, add a motion actuator to fling in the Z axis, with some rotation. (see below)

On the debris - Delay 0---------and----------Motion lin v 5, ang r 5 or whatever.
Delay 20--------and-------state 2 this will send them flying, then fall to earth.

Now add these to the hangers logic so they all appear when the missle collides with the hangar.

Tested on 2.76b, and UPBGE 2.78

For Static collision detection one of the objects MUST be a sensor object. Whether this means parenting a sensor on top of an existing static object is up to you. Selecting actor won’t affect the result for static ->static.

Hi Tim. No, not true, the missile is dynamic, the hangar is static. it works in my tests.
Test the way I described it. It works. :slight_smile:
I could post a blend, if need be.

Selecting actor won’t affect the result for static ->static.

Right . . . I think. :slight_smile:

P.S. And the hanger dosen’t need to have the collision bounds ckecked in the physics panel.

For Static collision detection one of the objects MUST be a sensor object.

This is true. 2 static objects won’t collide with each other.

dynamic will work, should work and does work.
Just don’t use static objects for things that move. (exception for moving platforms, etc)

so…

tank = dynamic
place an empty in front of the tanks barrel, parent the empty to the barrel/tank.
let the empty spawn a missle, this missle will be dynamic, collision bounds sphere/box (depending on the missle looks).

tank done, now the hangar.

build your hangar, dont change any of the physics settings.
at the spot you want to spit out tanks, place an empty, let that empty spawn the tank.

now you got a building spitting out tanks, tanks can shoot missles, missles fly to wall and collide.

also be sure to check collision box/sphere for the bullet, leave the walls as is (meaning spawn a cube make a wall out of it and dont change a thing at physics). for the bullet, make it dynamic, collision bounds sphere/box. let an empty spawn the bullet with some velocity(speed), it will fall down over time(like a real bullet) at more speed and increase spawn hight to get a goot looking bullet flying to its target.

Note.
Don’t give the bullet a to high speed, else it will skipp the collision detection and fly straight trough.
best way is to shoot a ray in front of the flying missle, but i guess thats a bit to advanced for you at this time.

http://pasteall.org/blend/index.php?id=46215 super simple example with bricks. A pro would probably use a script to replace the mesh

He forgot to say press Enter/Return key to shoot a cannonball

Changing meshes is something a beginner can do(i thought that there is a brick for it as well(edit object -> change mesh))

the python variation:


def change_mesh(obj, mesh_name):
    
    mesh = obj.meshes[0].name


    if mesh != mesh_name:
        obj.replaceMesh(mesh_name)

The instructions are in the scripts panel. :slight_smile: As you can see, there are no sensors, and it works. ( by sensor, I mean instead of static, dynamic, etc.)

You don’t have to use dynamics or ridgid body on the tanks, you can use static, if you want. Just beware that the tanks will go threw walls, and not follow the terrain, or fall. But there are cases where this might come in handy, a ghost for example, fully rigged with bones, but you want him to float and go threw walls, or rats running in and out of a scrap heap. Or if too many npcs are dragging the frame rate down. perfectly fine to use static. IMHO

Agreed, Edit object > replace Mesh, is something a beginner can do. :slight_smile:

The instructions are in the scripts panel

your right sorry readed over the first line xD

You don’t have to use dynamics or ridgid body on the tanks, you can use static, if you want. Just beware that the tanks will go threw walls, and not follow the terrain, or fall

you actually counter yourself, i agree on a flat surface it my come in handy to use static, but to be honest i dont see a reason why you dont put it on dynamic.

things that move = dynamic (anything but static, except for moving platforms)
things that are not being used, or not moving, etc. should be static.

But there are cases where this might come in handy, a ghost for example, fully rigged with bones, but you want him to float and go threw walls, or rats running in and out of a scrap heap. Or if too many npcs are dragging the frame rate down. perfectly fine to use static. IMHO

No it is not perfectly fine, they made the ghost option for it, use that one, dont use static. if you want to go trough walls, ghost is an option, or set it to no collision, either way both are better then static.

Hmmm, you could be right, But I have used static in a few of my games, and it ran perfectly fine. A gamer who wasn’t a dev. wouldn’t know the differance. In one game, too many dynamic npc’s dropped the fps so it couldn’t be played. So i changed them to static, and it worked fine. But you are probably right, there could be a better way.

If it were Ghost, wouldn’t it drop through the floor? Still, a track to closest script, or track to actuator could solve that. (see I counter myself) LOL

As for counter myself . . . I do it all the time LOL. Hmm on the other hand . . . LOL

Thank you guys, OP here, really valuable information,

it seems I have messed things up a little bit, because my projectiles are static (it was easier to program their ballistic trajectory this way)
Since tanks were dynamic, it was not a problem…

…until now, that I want a destroyable hangar and also need the projectiles to not go through walls (which are also static) ---->Unsolvable, unless…

…projectiles are made Dynamic. So this is what I will do next.

A little issue is that =

I would like gravity to not interfere with the projectile.
Is there some easy way to turn off gravity, but keep collision, on a Dynamic object ? Unchecking Physics seems to disable collision as well.

Thanks anyway, you are very helpful
Dimitris

give the missle an upforce, 9.8 is default gravity, so with bricks i would just do, always - motion - apply z force.
or dive into python and learn how to shoot rays in front of the missle, then you can leave it static.

Great, upforce 9.8 worked.

This is the best advice. that actually solved many of my problems.

Thanks mate!