Game Development Community

LevelLoading problem

by Eric Schwegler · in Torque Game Builder · 08/14/2006 (5:33 am) · 2 replies

Hi,

is it possible to load a level on collision?
For example, if the player collides with a hole, can't I do this:

function Player::onCollision(%srcObject, %dstObject, %srcRef, %dstRef, %time, %normal,
%contacts, %points)
{
if (%dstObject.class $= "Level2")
{
sceneWindow2D.loadLevel("ProjectName/data/levels/level2.t2d");
}
}

(Where "Player" is the Player Class and "level2" is the hole class)
?

Because it crashes everytime on collision...?

Can somebody help me with this?

Thx

#1
08/14/2006 (6:21 am)
I think it's probably because you're trying to load a new level inside a callback.That kind of pulls the rug out from under your program.

Try adding a short delay with 'schedule' -- something like this (replace your current 'loadLevel' line):

sceneWindow2D.schedule(1,"loadLevel","ProjectName/data/levels/level2.t2d");
#2
08/14/2006 (7:53 am)
Yes, it works that way!
That's so great, thank you so much!