Cillisions on moving objects

Blitz3D Forums/Blitz3D Programming/Cillisions on moving objects

PowerPC603(Posted 2004) [#1]
Hi,
I created a testscene with 2 spheres.

First I tried to move the right sphere towards the left sphere and to let it stop on impact.
That worked.

Then I also let the left sphere move away from the right sphere a bit slower than the right one (so they can collide).
They collided and the right sphere just followed the left one at the same speed, because it was always bumping into the left one.

At last I tried moving them towards each other and they moved right through each other.

I tried to use 2 UpdateWorlds (move the right sphere, updateworld, move left sphere, updateworld), without succes.

Then I assigned some sort of two-way collisions, that worked.
Is that the way to go, when you have 2 moving objects and you want each of them to collide with each other?

As I'm trying to create a spacesim, but the AI must be able to collide with you, and you with the AI-ships.

Graphics3D 800, 600, 0, 2

SetBuffer BackBuffer()

; Create objects
sphere1 = CreateSphere(100)
sphere2 = CreateSphere(100)
camera = CreateCamera()
light = CreateLight(2)

; Position objects
PositionEntity sphere1, 5, 0, 0
PositionEntity sphere2, 0, 0, 0
PositionEntity camera, 0, 0, -10
PositionEntity light, 0, 10, -10

; Set collision types
Sphere_Left = 1
Sphere_Right = 2

EntityType sphere1, Sphere_right
EntityType sphere2, Sphere_Left

; Set collision radius
EntityRadius sphere1, 1
EntityRadius sphere2, 1

; Set collisions
Collisions Sphere_Right, Sphere_Left, 1, 1 ; Let right sphere collide with the left one
Collisions Sphere_Left, Sphere_Right, 1, 1 ; Let left sphere collide with the right one

While Not KeyHit(1)
	Cls

	MoveEntity sphere1, -0.025, 0, 0
	MoveEntity sphere2, 0.005, 0, 0

	UpdateWorld
	RenderWorld
	Flip
Wend

End


Doesn't this create a huge drop in performance, if you have about 30 ships in view, each colliding with each other?

Also, could I do this?
; Set collisions for AI-ships
AI_Ship = 3

Collisions AI_Ship, AI_Ship, 1, 1


So each AI-ship can collide with each AI-ship, without one ship passing through another one (uncollided).

I know it would be better to create a good collision-avoiding routine, but just in case they would collide (would seem like a bug for most players who would play your game) if AI-ships don't collide with each other.


PowerPC603(Posted 2004) [#2]
Tried that "Collisions AI_ship, AI_ship, 1, 1"-thingie and it works.

And I use only one UpdateWorld.

Is that the way it is supposed to work, as I'm new to doing collisions (didn't write a game yet).

I did create some tools (a videoplayer to take full-screen screenshots) and some test-routines.

I'm not new to programming, 'cause I created lots of tools with Visual Basic 6.0 Enterprise Edition.
Even did a project to control some custom hardware on the parallel port in a serial way (sending bitstreams one one dataline to control the hardware).


jfk EO-11110(Posted 2004) [#3]
I am surprised that this works with only one Updateworld. Usually you need one for each object that would move towards an other one, as you described with the 2 spheres. But you're right, Collisions x,x,... is the way to go. Welcome on board BTW and good luck with your space sim.


RGR(Posted 2004) [#4]
;-


PowerPC603(Posted 2004) [#5]
@ jfk:

I tried to use two UpdateWorlds:
MoveEntity Sphere1, -1, 0, 0
UpdateWorld
MoveEntity Sphere2, 1, 0, 0
UpdateWorld

RenderWorld


But the two spheres didn't collide with each other, with only collisions set from sphere1 to sphere2.

Setting up collisions both ways (from sphere1 to sphere2 and reversed) did the trick, as in my first post.

Then also only 1 updateworld is needed.


Another question:

I created a test-station in 3DS max and exported it to b3d, using the B3D pipeline, with a scene-root added while exporting (so all other objects are children to this scene-root).

I can load the station using LoadAnimMesh, that works perfectly.

But to set up collisions (from player-ship to station), must I:
- set an entity-type to all children, without setting an entity-type to the scene-root (guess this is the one, not sure)
- set an entity-type to the scene-root and to all children
- only set an entity-type to the scene-root

Just to be sure.

I think it's the first one, as I think the scene-root is just a pivot, with all children (the objects in 3DS max) attached to it, and colliding only with the scene-root is actually stupid (sphere to polygon collisions).