Launch an object

Hi,

How does one launch an object?

For example, have a cube and make it fly forward at velocity 1 and have it collide with an other rigid body coming from an opposite direction also with velocity 1, and see where they both fly of to.

A tutorial or some words of wisdom would be great,

thanks,

m.

You could apply a force to your rigid object for a split second. To do this, use an always sensor set to tap. Connect it to a motion actuator set to servo control. Because the always sensor is on tap, it will only send one positive pulse at the start of the game engine. The servo control will apply the force on your rigid body object for that 1 logic tick. This will effectively launch your object.

Yes, great!! That’s it, works like a charm, thanks!

One more question how does one shut off gravity, so the object won’t be falling down, and keeps on moving straight forward? Of course adding a Passive floor would be a solution, but I was hoping that gravity could be turned off somewhere for the whole scene.

Edit: And one more question, why isn’t it possible to use ‘Mesh’ for 'Rigid Body Collisions" in the BEG while it is possible in ‘Blender Render’ tools? Is there perhaps a good alternative work around for this?

For the WHOLE scene? I believe in the world tab and there is physics with a gravity scroller thing. If you set that to 0 or set Physics Engine to none. This is in Blender Game.

For Blender Render its in Scene tab and there is a option ‘Gravity’.

you can have global gravity on, and turn off gravity for the object like this

always---------------and-------------motion Force [X=0,Y=0, Z= (mass*9.8)]

this is nice for scenes with things with and without gravity, (like space soldiers with magnetic boots + stuff tumbeling about

homemade friction =

always--------python

in text window


import bge
import mathutils


cont = bge.logic.getCurrentController()
own = cont.owner
Velocity = own.getLinearVelocity()
Velocity.x = Velocity.x*.95
Velocity.y = Velocity.y*.95
Velocity.z = Velocity.z*.95
own.setLinearVelocity(Velocity,1)

Attachments

Friction.blend (436 KB)

update

import bge
import mathutils

cont = bge.logic.getCurrentController()
own = cont.owner
Velocity = own.getLinearVelocity().copy()

own.setLinearVelocity(Velocity*.9,1)

works just fine

Thanks ‘DarkFire963’ that was an quick and easy fix, was everthing in life this easy :stuck_out_tongue:

And thanks ‘BluePrintRandom’ for the script, it’s good to know that it’s possible to ‘swich on / swich off’ each object individually, but I’m taking the easy way for now.

One question left unsolved is how to apply a ‘mesh’ collision in the BEG, because when using 0vals they collide at their centers and not on their outer side (mesh). See attached file: launch_ovals.blend (114 KB)

… or should I do this type of collisions in the ‘Blender Render’ scene, but how do I then launch these objects, as I can do now within the BGE?

Blender Game mode > physics properties > use colision bounds>triangle mesh/convex hull.

Jooeeehooe F**K YEAH!! That’s it!

Thanks, Johnny!

Edit: this thing is Solved for me.