Game Development Community

Have collision call late problem.

by Tim Kin Chu · in Torque Game Builder · 04/27/2006 (12:51 am) · 20 replies

//---------------------------------------------------------------------------------------------
// Torque 2D. 
// Copyright (C) GarageGames.com, Inc.
//---------------------------------------------------------------------------------------------


//---------------------------------------------------------------------------------------------
// setupT2DScene
// This function is the starting point for all game specific code.
//---------------------------------------------------------------------------------------------
function setupT2DScene()
{
   // Create our scenegraph
   new t2dSceneGraph(t2dScene);

   // Associate Scenegraph with Window.
   sceneWindow2D.setSceneGraph( t2dScene );
   
   // Set the current camera position
   sceneWindow2D.setCurrentCameraPosition("0 0 100 75");
   
   t2dScene.setDebugOn(1);
   
      //-----------------press "q" to debug---------------------
     // Create a new action map.
     new ActionMap(debugMap);
     // Bind keys to actions.
     debugMap.bindCmd(keyboard, "q", "test();", "");
     // Activate the action map.
     debugMap.push();
   //-----------------------------------------------------
      
}

function t2dSceneObject::onCollision(%srcObj, %dstObj)
{
   %srcObj.setAtRest(); 
   %dstObj.setAtRest(); 
   echo(%srcObj SPC %dstObj);   
   
   %srcObj.schedule(1000, "safeDelete");
   %dstObj.schedule(1000, "safeDelete");
}

function test(){
   
   
      // Load Test Collision Objects   
      %test1 = new t2dStaticSprite(object1) {sceneGraph = t2dScene;};   
      %test1.setImageMap(asteroidsImageMap);   
      %test1.setSize("10 10");   
      %test1.setPosition("50 0");   
      %test1.setLayer(29);   
      %test1.setGraphGroup(6);   
      %test1.setCollisionActive(false, true);   
      %test1.setCollisionPhysics(false, false);   
 
      %test1.setCollisionCallback(true);   
      %test1.setCollisionGroups(5);   
      %test1.setLinearVelocity("-60 0");
      
   %test2 = new t2dStaticSprite(object2) {sceneGraph = t2dScene;};   
   %test2.setImageMap(asteroidsImageMap);   
   %test2.setSize("10 10");   
   %test2.setPosition("-50 0");   
   %test2.setLayer(29);   
   %test2.setGraphGroup(5);   
   %test2.setCollisionActive(true, false);   
   %test2.setCollisionPhysics(false, false);   
   %test2.setCollisionCallback(false);   
   %test2.setCollisionGroups(6);   
   %test2.setLinearVelocity("30 0");   
}
the proble is .:

when the two image overlap then the collision call back will be called

but it is supoosed that the callback function called when they touch.

Do anyone have the same problem?????????

#1
05/02/2006 (7:58 pm)
Hey........
none have this problem???
#2
05/03/2006 (6:42 am)
I have a collision problem that sticks two objects that collide together, even though the method is supposed to be "CLAMP". But that's not your case.

Collision occurs when two object overlap at least their collision polygon. One way of solving this could be setting your collision polygon to be slightly smaller than the bitmap. So you'll garantee that colision will happen only after they overlap a bit of each other.
#3
05/04/2006 (1:02 am)
I want the function called when the objects touch each other.

My problem is, the function get called when the two object overlaping.
#4
05/04/2006 (6:38 am)
The easiest way to solve it is making a larger collision polygon instead.

But I'm not sure if I understood your question. Are you saying that a missile is only killing the ship after it's over it ?
In this case, it might be a performance problem. Are you using OpenGl or D3D ? I just had some problems with collision in OpenGL, try using D3D instead.
#5
05/07/2006 (9:35 am)
Yes.

It is the problem.

The collision will be detected when they are overlap sometime, but also will detected when they nearly touch.
@@
Make the collision polygon cannot solve this.



How to use D3D instead of openGL???
#6
05/07/2006 (4:58 pm)
Check common/prefs.cs

see if this is set :

$pref::Video::displayDevice = "D3D";
$pref::Video::allowOpenGL = 0;
#7
05/07/2006 (9:36 pm)
I changed my setting to.:
$pref::Video::displayDevice = "D3D";
$pref::Video::allowOpenGL = 0;

But it is still the problem.
#8
05/08/2006 (2:59 pm)
Tim, check in the console.log if D3D is REALLY enabled. You could have this set but T2D may be falling back to OpenGL in case D3D isn't installed properly.
#9
05/08/2006 (9:11 pm)
Video Init:
Accelerated OpenGL display device not detected.
Accelerated D3D device detected.
Voodoo 2 display device not detected.

Activating the D3D display device...
Setting screen mode to 800x600x32 (w)...
Creating a new window...
Acquiring a new device context...
Pixel format set:
32 color bits, 32 depth bits, 0 stencil bits
Creating a new rendering context...
Making the new rendering context current...
OpenGL driver information:
Vendor: Microsoft Corp.
Renderer: Direct3D
Version: 1.1
OpenGL Init: Enabled Extensions
ARB_multitexture (Max Texture Units: 2)
EXT_paletted_texture
EXT_compiled_vertex_array
EXT_texture_env_combine
EXT_fog_coord
OpenGL Init: Disabled Extensions
EXT_blend_color
EXT_blend_minmax
NV_vertex_array_range
EXT_packed_pixels
ARB_texture_compression
EXT_texture_compression_s3tc
3DFX_texture_compression_FXT1
(ARB|EXT)_texture_env_add
EXT_texture_filter_anisotropic
WGL_EXT_swap_control

OpenAL Driver Init:
Vendor: Creative Labs Inc.
Version: OpenAL 1.0
Renderer: Software
Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3
#10
05/08/2006 (9:12 pm)
Which part show that D3D is really enabled??
#11
05/09/2006 (12:21 pm)
Unless you rebuilt beta2 yourself, none in the end (the dlls present with t2d.exe indicate that).
#12
05/09/2006 (11:42 pm)
Your meaning is ?????????
rebuild a debug version???
#13
05/10/2006 (7:02 am)
I would say D3D is enabled thru this part of the console :
Quote:
Video Init:
Accelerated OpenGL display device not detected.
Accelerated D3D device detected.
Voodoo 2 display device not detected.

Activating the D3D display device...

But Beta 3 has just been released. Try downloading it and see if it solves your problem
#14
05/10/2006 (8:04 am)
It should as beta3 has the dlls back in which are needed for DirectX to work.
#15
05/10/2006 (7:51 pm)
Where can I download the beta3???
#16
05/11/2006 (7:16 am)
Go to your account page and click on the TGB product link.
#17
05/12/2006 (11:29 am)
Tim from your other posts. I guest you are making a bubble puzzle game. The concept of this type of game is not to let the balls set their postion when they collide but we should make a function to calculate the right position for the balls ourselfs when the ball collide ...


so you get more idea of it ,go read my other post it is just below this post ....
#18
05/18/2006 (12:56 am)
Yes....

What I did in my game is
1. the player shoot the ball.

2. set velocity to the ball.

3. wait collision.

4. collision call back.

5. set it to correct position.


The problem is the collision is detected when the balls ovetlap.
And the position set is depend on the point of collision.

So, the setposition in step 5 will be wrong.
#19
05/18/2006 (1:05 am)
Why don't you set the position when collision by using the %src object position
#20
05/18/2006 (7:56 pm)
UM............
%src object is the ball shoot out??

what is your method to set it to the posiont??

My method is set the positoin ( up , down , right ,left ..... ) by the point they touch...

So, the where the touch point is worng , the posiiton is worng.