Game Development Community

Imaginary object impacts when using impulse

by Matthew Cooke · in Torque Game Engine · 04/03/2004 (7:42 am) · 18 replies

I have added a 'boost' function to my player with the following code:

function serverCmdCharge(%client)
{  
   %vec=Vectorscale(Vectornormalize(%client.player.getEyeVector()),8000);

   //remove z component of impulse to keep player on ground
   %vec=setWord(%vec,2,"0");
      
   %pos=%client.player.getPosition();
   %client.player.applyImpulse(%pos, %vec);
}

This is mapped to the space bar. And so by repeatedly pressing the space bar the player can zoom around the map at quite a pace.

However every once in a while (Every 20 seconds or so if zooming around constantly) The player collides with an object that is not there. This usualy causes damage, or sometimes just shakes the camera.

Adding an echo to the following function in player.cs

function Armor::onImpact(%this, %obj, %collidedObject, %vec, %vecLen)
{
   echo("IMPACT: "@%vecLen);
   %obj.damage(0, VectorAdd(%obj.getPosition(),%vec),
      %vecLen * %this.speedDamageScale, "Impact");
}

Gives me results such as:
Quote:
IMPACT: 55.285328
IMPACT: 50.40 ...
IMPACT: 53.29 ...
IMPACT: 66.00 ...
IMPACT: 50.40 ...
IMPACT: 51 ...
IMPACT: 62 ...
IMPACT: 57 ...

I haven't found one with a speed <50

I have seen a mention in this thread www.garagegames.com/mg/forums/result.thread.php?qt=13687 regarding a speed limit over which the game crashes. Could this problem be related?

Any help would be appreciated. Explaining to the user why he keeps dying unexpectedly might be a bit awkward.

Many Thanks
Matt

#1
04/03/2004 (7:45 am)
I tell a lie. I just got one with speed 45.278313.

Now I'm REALLY confused.
#2
04/03/2004 (7:58 am)
Sorry for the diarrhea of posts. But I just took the blindingly obvious step of printing '%collidedObject' from onImpact.

My player is colliding with the terrainblock?!?

My terrain is dead flat, and I am taking the z component from the impulse vector. So why is it acting as if it has fallen from a height.

Can anyone enlighten me? I guess worst case I could remove fall damage. But can you remove fall damage while still including damage from colliding with a building say?
#3
04/03/2004 (11:53 am)
I noticed this problem too when I was making players run around really fast. I just didn't notice the damage part because I had set the fall damage scale to 0. The same onImpact function is called for colliding with a building or terrain, but you should be able to get the type of collided object and decide whether or not to apply damage. I'm not totally sure you can check an object to see if it is a terrain block or an interior, only because I've never tried. I assume there is some sort of information you can derive from the object that will get you this though. You own the SDK, so I'm sure you've got better resources for finding that than I do.
#4
04/04/2004 (10:16 am)
Thank you for your reply, it confirms that I'm not going mad and my code is not at fault (in this case :) )

Following your suggestion I added the following line to onImpact

if( %collidedObject==Terrain.getId() )
      return;

This means no damage is caused by falling or by these anomalies, but still caused by normal impacts. It does however mean that the player still stops dead or the player's camera shakes on an anomaly.

However does anyone know why this is happening? Is there a certain speed it will occur at? (so I can limit myself below it)

Many Thanks
Matt
#5
04/04/2004 (11:00 am)
Try
echo("collidedObject: "@%collidedObject);
and if that gives a number just put %collidedObject.getname() :D hope that helps
#6
04/04/2004 (12:35 pm)
Are you actually using the default player datablock to run around? It sounds like you are doing some sort of racing deal here, so wouldn't you want to use the hover or wheel typed vehicles? I've never used them, but I imagine they don't have the same problems.

You said this is happening on flat ground, so it might not help, but you could also try changing the "runSurfaceAngle" angle value in your player datablock and see if that helps.
#7
04/04/2004 (1:19 pm)
Its not a bug , its a feature. :)
It was in Tribes and Tribes2 and it gets worse with flat terrain, Id like to know how to prevent this.
#8
04/04/2004 (3:00 pm)
I wonder if this might have to do with the players computed collision bounds... As I undrstand (though I could be way off) When a player object is moving, it's bounding box is resized to reflect the distance the player will travel during that time slice. It could be that the code is not designed to handle the higher numbers of very fast speeds. So at some point it might be creating a bounding box that is much larger then the actual distance the player will travel in that time slice, thus with this oversized box, it would detect a terrain collision when it shouldn't. There are some problems with vehicle code alonge these lines, which is why I suspect it in this case as well.
#9
04/06/2004 (2:13 pm)
Looking into this abit , im thinking that its caused by a strange collision normal from the edges of the terrain tiles.
#10
04/07/2004 (11:26 am)
Interesting, is it perhaps because the terrain convexes aren't actually convex?
#11
05/04/2004 (8:33 am)
I'm bumpin this because I've always been very concerned with this. Especially when it was in the Tribes worlds.
#12
08/09/2004 (1:35 pm)
Another bump.
I having the same problem. Any one have a clue/solution?

I tweaked some value in the player classm, it decreased the number of "bumps" but the player can still hit something and change direction on a flat surface when running.
#13
08/11/2004 (8:39 pm)
I think the only way this problem is going to get solved is if somebody sits down and really analyzes the data. This problem has been in Legends for some time and they have yet to solve it. It's pretty subtle.
#14
08/14/2004 (12:57 pm)
Any more work done on this?? You know, I think I saw it before, but I did a bunch of changes to the player to make them less "floaty" (forgot what exactly), and I dont remember the last time I saw this behavior...

-s
#15
08/14/2004 (1:03 pm)
Well cant you visually check the boundign box by turning them on?
#16
08/14/2004 (4:40 pm)
The only thing i could think of was to filter out the abnormal normal and repace it with the last normal normal ,but i didnt bother trying yet. I wish i knew more so i could analyze the data.
#17
12/09/2004 (11:45 pm)
I'm seeing this problem too. I don't have time to really deal with it, so I got around it by giving my players a vertical impulse when they do their speed boost. This gets them off the ground a little, similar to jumping, and off the terrain. It solved the problem, but it obviously won't work for everyone. If you're running around fast all the time, this won't help you, because when the guy gets back to the ground, his velocity gets affected. My speed boost just happens to be more like a running dive, so it works for me.
#18
12/10/2004 (10:25 am)
The best you can hope to do right now is move around in the editor and when you come to a dead spot, raise or lower that piece of the terrain you got stuck at. I am going to take a stab at a script hack since I am running into this problem frequently in a little project Founder and I are working on.