BLast processing (high speed collision code, the simplest one!)

what game engine does have blast processing, to get the fastest action?
now, BLENDER DOES

http://s2.subirimagenes.com/privadas/previo/thump_134599blast.png

Well i couldn’t find a better name for this xD, is basically a ray-based collision prediction system that allows you to go at ridiculous speeds (tested at 850km/h) without even worrying about walls or floors, it just stops in the instant. so you can now kick that 40m/s limit


## bad-ass highspeed collision system 
## (c)2008 by Cyborg_ar, you may
## not alter or remove this copyright notice.  
import GameLogic 
 
cont = GameLogic.getCurrentController() 
own = cont.getOwner() 
clk = cont.getSensor("clk") 
 
if clk.isPositive(): 
    pos = own.position 
    vel = own.getLinearVelocity() 
    diam = 1 #the diameter of the bound 
    target = [pos[0]+vel[0]/20*diam, pos[1]+vel[1]/20*diam, pos[2]+vel[2]/20*diam] 
    if own.rayCastTo(target,0,"") and not own.rayCastTo(target,0,"ghost"): 
        own.setLinearVelocity([vel[0]/1.6,vel[1]/1.6,vel[2]/1.6])

the setup cant be simpler, just put the script in a python controller, and connect an always sensor called “clk” with pulse mode enabled

to show off this cool addon i made this blend you can download (svn 15500 and above, or 2.47)

Just start it and press the spacebar, you can look the real velocity in meters/second in the debug properties. also try the blend without the blast processing and you will see how it fails xD.

if you put ghost objects in your level, you’ll have to apply a property called “ghost” to tell the blast processor to ignore that object, you can apply the property massivelly using the super handy control-c

also, there is a variable in the script called diam, there you put the approximate diameter of the object that has the script.

Attachments

blast.blend (147 KB)

Awesome!

Awhile back, I remember that there was one high speed collision detection method that worked similar to his in 2006. And I think Captain Obvious made an improved system back in 2007.

But this is still nice. We finally get to use the rayCastTo() function for speed rather than using an empty.

xD i know but this one is the simplest way possible to set it up xD also please note that all the post was intended to be tongue-in-cheek :stuck_out_tongue:

also please note that all the post was intended to be tongue-in-cheek :stuck_out_tongue:
Sorry, I was just stating the facts, I did not mean to sound harsh.

Anyways, this appears to be the simplest script for collision that I’ve seen. It should work well for most objects. =)

I <3 you … in a friendly way :stuck_out_tongue:

I had made a high-collision system for small projectiles a while back (as mentioned by C-106).

this looks a lot more versatile than that version, and easier to set up. nice job : )

Sweet!

Now we can have ultra fast racing games without worrying about collision problems. Thanks for the script = )

This is really cool! If only I had a need for it :frowning:

Woah! Tested it up to 1200-1500 mp/h or is it km/h ? I don’t care! I’ts awesome! YEEhA!

wow.

i know where this code is going.

coughBastardizedcough

zymn, that’s obvious, i will not code anything i don’t need (unless someone is paying me to do it, but that makes me need to code it anyway). that’s the spirit of open source. work less at the same time you make others work less xD

btw, the script works in ANY direction, cuz its aligned to the speed vector, so the only thing that is not yet completelly automatic is the recognition of ghost objects (ghost actors, not real ghosts that have no collisions) but well, the setup cant be simpler just add the ghost property to one ghost, select all ghosts (keeping the one with the property active) and press control-c and then “properties” select “ghost” and there you go

btw2, After much deep and profound brain things inside my head, i remembered that setLinearVelocity() is not available until svn 15500 xD so it would not work in 2.46

umm…
it really doesn’t seem all that fast…
i mean, i wanna see it on large areas, you know?
with a camera and stuff.

which is why i can’t wait for your sonic game.

btw, why not have sonic rotate?
i mean, control would be much easier if he rotated when you pressed the left and right arrows…

did you see the latest build i made of my game? (the one made 3 days ago with the big level and such)

btw, the script works in ANY direction, cuz its aligned to the speed vector,
Didn’t the other scripts do this too? I can’t remember… But it’s awesome that your’s does.

so the only thing that is not yet completelly automatic is the recognition of ghost objects (ghost actors, not real ghosts that have no collisions) but well,
Most (if not all) scripts had this problem. Wouldn’t it be easier to just have the ray detect a property? That would save you a lot of trouble and it would allow it to be a bit more flexibility.

btw2, After much deep and profound brain things inside my head, i remembered that setLinearVelocity() is not available until svn 15500 xD so it would not work in 2.46
True, but by now, you should know that there is always more than one way to “fry a fish”. There is one other way to reset/set the Linear Velocity (the same goes for Force).

actually this way is better because you will probably have less ghost objects than normal objects.

yes, using a motion actuator as i did before until the revision 15413 was commited (i compile every week or when there is a very important update) also the motion actuator is 1 frame off, wich caused some issues with my script until this function was added

Revision: 15413
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15413
Author: campbellbarton
Date: 2008-07-03 03:34:50 +0200 (Thu, 03 Jul 2008)

Log Message:

Adding GameObject setLinearVelocity(), without this interacting with objects requires them to have logic bricks to apply force which doesn’t work well when the character is in a seperate blend file to the levels. (its also messy to have a script & multiple motion actuators on each object you can pickup and throw).

This is also needed for removing any force that existed before suspending dynamics - In the case of franky hanging, resuming dynamics when he fell would apply the velocity he had when grabbing making dropping to the ground work unpredictably.

Also note in pydocs that enable/disable rigidbody physics doesn’t work with bullet yet.

finaaaaaaaaaaaally… :wink:

Adding GameObject setLinearVelocity(), without this interacting with objects requires them to have logic bricks to apply force which doesn’t work well when the character is in a seperate blend file to the levels. (its also messy to have a script & multiple motion actuators on each object you can pickup and throw).

missed that update… but can you set the angular velocity as well now… with out an actuator… should you want to remove it…?

actually this way is better because you will probably have less ghost objects than normal objects.
Yea, I have to agree with you there. But you still might want to consider use a property. There are some “rare” situations where you don’t want your object to be stopped by other objects. You might also find problems if your character interacts with other dynamic objects (usually objects that have less mass than your character). I’ve done this type of thing before, just trying to give you a heads up. =)

Of course, you might not have problems with it… I guess it depends on your game and what you have in it.

did you read that objects with the “ghost” property are ignored?

this is great and simple. I like it! btw cyborg…there is some things i want to talk to you about…about your engine i am currently using. When i finish my classes, ill be working on my own slope engine and what not!

oh and good news, im taking spanish so, i can speak with you in pro-status. :stuck_out_tongue:

The maximum seems to be like 1000 m/s!
Awesome!
By increasing diam, it could be alot higher :slight_smile:
I didn’t know there was a rayCastTo() function. It can be used for simplifying FPS bullet detection.