Game Development Community

Movement problems

by Martin Andresen · in Torque Game Builder · 07/13/2006 (7:27 am) · 5 replies

Hi,

We've recently started using TGB and are working on our first game using this.

We wanted some objects to follow a specific path, and looked into using t2dpath for this. However, we've come across some problems. For instance when running the engine in Windowed mode if you left-click the title bar, all rendering in the window is stopped. If you release the mouse again after a few moments rendering continues, however moving objects have moved some distance along their current direction, ignoring the path they were travelling along. The objects then travel towards the next node in the path they were following.

Other than it will look weird to the player that the object travels away from the path, we have mulitple objects travelling along multiple paths. These objects may not collide, but if the objects travel away from their current paths, we really have no way of preventing the objects from colliding where they shouldn't have had a chance to collide, thus breaking our gameplay.

We noticed that this is a general movement issue (f.ex. also in the Fish Demo).

Has anyone had similar problems and found a fix or work-around for it?

- Martin

#1
07/13/2006 (5:19 pm)
I was having a very similar problem - to fix it (on a Mac, at least), I altered the event handling in macCarbWindow.cc, essentially adding:

if (!gCursorHidden)
     Con::executef( 1, "mouseDownInTitleBar" );

in the kEventMouseDown check, and

if (!gCursorHidden)
     Con::executef( 1, "mouseUpInTitleBar" );

in the kEventMouseUp check. The "if(!gCursorHidden)" condition tells me if the mouse event occurred in the title bar because the cursor is hidden everywhere else within the window ( by default, at least ).

So in my script I call:

function mouseUpInTitleBar() {
	
	gameSceneGraph.setScenePause( false ); 
}

function mouseDownInTitleBar() {
	
	gameSceneGraph.setScenePause( true ); 
}

...and the game pauses while I drag my window around, and unpauses when I'm done.

Don't get me wrong, I know this is a nasty fix, but my C++ skills (and Carbon knowledge) are pretty non-existent, and it works for what I need. I think some proper hooks into these kinds of event would be a nice addition to the engine, though.

Chris
#2
07/14/2006 (6:16 am)
Thanks Chris, this was what I was looking for.

However, I'm doing this on Windows. I've looked into doing something like the above, and did get a few ideas on how to solve it, but I would appreciate it if anyone who have done anything like this could give a few pointers on what they did.

- Martin
#3
07/19/2006 (1:14 pm)
Haven't anyone experienced anything like this in Windows?

Whenever objects are moving, for example along paths or merely using setLinearVelocityX, when dragging the window, switching between windows etc., the graphics are not updated. When updating again TGB calculates how much time passed since the last render and depening on the objects speed moves the object accordingly in the direction it was travelling. Especially when it was supposed to follow a turn on a path, this is really annoying as the object can get way out of position from where it should be.

Haven't anyone dealt with these issues in Windows?

- Martin
#4
07/19/2006 (11:32 pm)
I've definitely seen it, and it's annoying. I don't know at all how to fix it though. Just thought I'd chime in because your post seemed a bit lonely, and this issue should probably be looked at. :)

But at the same time, it's kinda good that it's in there, or else online multiplayer games could get pretty screwed up from desyncing.
#5
07/26/2006 (11:39 pm)
I'm definitely in the same boat, I myself being new to TGB. I don't have any serious game building efforts going on at the moment as I'm still fiddling around with the engine itself, but recently I've discovered this issue for myself just last night and find it to be very alarming.

In my case, I set up a simple clear level with 12 different balls, all set up to have an initial momentum to either the left or the right, to have a gravity constantly pulling them down, each ball is set at a heights different from one another, and are set to bounce off their world boundaries (set to the size of the view). Upon testing the level, everything seems to work just fine, watching all the different balls move and bounce off the floor and walls, but minutes later every now and then I'll notice that a ball mysteriously vanishes, and every few minutes later another ball might go. But the real kicker is when I click on the top bar of the window or press ALT+Enter to toggle the game into full-screen mode (or vice-versa), I notice that anywhere from 30% to 60% of all the balls will immediately disappear, and any balls that were settled on the ground and no longer bouncing were immediately recoiled back into the air to begin bouncing again. Sometimes I can get it to happen just by switching the focus to another application such as Winamp or even Notepad and Calculator.

Being new to Torque, I'm not entirely sure what my options are, but for the games that I have in mind that involve precision movement for multiple objects within a single level, this can be a huge problem for me.