Projectiles not colliding with player
by Amr Bekhit · in Torque Game Engine · 01/09/2007 (7:04 am) · 16 replies
Hello all,
I've recently been experiencing a strange problem. My projectiles are not colliding with the player. The projectiles seem to collide with the terrain fine and my player can trigger off trigger areas and pick up items but projectiles go right through. I've uploaded my player and projectile models (both in DTS and Maya 7 format) in case anyone wants to inspect them. You can download the zip file here.
Thanks
--Amr
I've recently been experiencing a strange problem. My projectiles are not colliding with the player. The projectiles seem to collide with the terrain fine and my player can trigger off trigger areas and pick up items but projectiles go right through. I've uploaded my player and projectile models (both in DTS and Maya 7 format) in case anyone wants to inspect them. You can download the zip file here.
Thanks
--Amr
#2
Aun.
01/09/2007 (7:15 am)
It happens when the projectiles are too small and running too fast. Have you tried decressing the projectile's speed?Aun.
#3
@Paul: I think I have. Here's the code for my Projectile::onCollide function:
But the thing is that the projectile code isn't being called at all. The projectile just goes straight through the player model.
@Aun: Thanks for the info. The projectiles are quite slow and large, but I did try and slow them down and enlarge them but unfortunately no success.
The strange thing was that before, I had implemented my player (a ship) as a HoverVehicle and the whole thing worked fine, then today I implemented it as a Player and that's when the problem started.
--Amr
01/09/2007 (7:33 am)
Thanks for your replies guys.@Paul: I think I have. Here's the code for my Projectile::onCollide function:
function CannonBall::onCollision(%this,%cannon,%col)
{
//First check to see tha the object we collided with is a shapebase object
//and that it isn't docking
echo("Cannoball colliding with something: " @ %col.docking);
if ((%col.getType() & $TypeMasks::ShapeBaseObjectType) && !%col.docking)
{
//The cannon ball has collided with an object, so let's decrement it's health
%col.Damage(%cannon,%this.damage);
}
}But the thing is that the projectile code isn't being called at all. The projectile just goes straight through the player model.
@Aun: Thanks for the info. The projectiles are quite slow and large, but I did try and slow them down and enlarge them but unfortunately no success.
The strange thing was that before, I had implemented my player (a ship) as a HoverVehicle and the whole thing worked fine, then today I implemented it as a Player and that's when the problem started.
--Amr
#4
you also might want to try specifying the player object mask explicitly:
$typeMasks::PlayerObject
or something like that. although it seems like it should work since player is derived from shapebase...
01/09/2007 (8:06 am)
Seems like that should work to me. maybe you need to tweak the collision box parameters in your player datablock.you also might want to try specifying the player object mask explicitly:
$typeMasks::PlayerObject
or something like that. although it seems like it should work since player is derived from shapebase...
#5
I must admit, I wasn't expecting that at all. I was expecting that Torque would use the bounds rectangle in my model, and that I wouldn't need to touch the boundingBox property. I'm not 100% sure whether it's the export of my model that's causing the problem or just simply my lack of experience with Torque.
--Amr
01/09/2007 (3:29 pm)
I've tried tweaking the boundingBox property of my player datablock and I have got collision now, so thanks Sean! I'm in the process of adjusting the seperate x, y and z values to get it right.I must admit, I wasn't expecting that at all. I was expecting that Torque would use the bounds rectangle in my model, and that I wouldn't need to touch the boundingBox property. I'm not 100% sure whether it's the export of my model that's causing the problem or just simply my lack of experience with Torque.
--Amr
#6
--Amr
01/09/2007 (4:57 pm)
Hmm this really is a strange problem. I switched from implementing my ship as a Player object to a HoverVehicle and it works fine using the very same models. I checked them in the Show Tool Pro and I can see the LOS and Col meshes. I'm using the latest version of TGE 1.5 with the advanced camera resource and the contents of Mat Fairfax's first post in this thread. For reference, here's my ship's player datablock:datablock PlayerData(GalleonPlayer)
{
shapeFile=$galleonMesh;
renderFirstPerson=false;
emap = false;
mass = 90;
drag = 0.3;
maxdrag = 0.4;
density = 10;
maxDamage = 100;
destroyedLevel=100;
disabledLevel=150;
runForce = 48 * 90;
maxForwardSpeed = 14;
maxBackwardSpeed = 13;
maxSideSpeed = 13;
boundingBox="1 1 1";
};--Amr
#8
torque uses the exported bounding box for everything except players and aiplayers which use a custom box defined in the datablock.
01/10/2007 (10:50 am)
It's not a problem it's a feature. =)torque uses the exported bounding box for everything except players and aiplayers which use a custom box defined in the datablock.
#9
01/10/2007 (11:13 am)
I test your models in my scripts, projectiles are colliding with the ship. I built an AI script drop on the water and launch my attack. The projectiles was hit the ship, it was take damage and attacking back then it sunk in the ocean. Cool ship! You might want to take look at your scripts.
#10
@Sean H: Oho! So even if I have Col and LOSCol boxes for my player model they won't be used? So what DO I use for players? Is it just a matter of adjusting the boundingBox parameter?
Thanks for the info so far guys!
--Amr
01/10/2007 (11:46 am)
@Fucifer: Thanks for testing my models, I appreciate it! OK so it seems that the model is fine and it's my scripts.@Sean H: Oho! So even if I have Col and LOSCol boxes for my player model they won't be used? So what DO I use for players? Is it just a matter of adjusting the boundingBox parameter?
Thanks for the info so far guys!
--Amr
#11
If so, how can I go about doing this? I can't see the bounding box, so it seems like I have to adjust values then test and keep doing that till I find the right size.
--Amr
01/10/2007 (11:54 am)
I've just had a quick look at my copy of the Game Programmer's Guide to Torque in the section where the author describes the datablock for his player (p226). From what I understand, Torque has a set size bounding box that it uses for all Player objects, and that it is my job to tweak it's dimensions to fit my mesh. Is my understanding correct?If so, how can I go about doing this? I can't see the bounding box, so it seems like I have to adjust values then test and keep doing that till I find the right size.
--Amr
#12
You can enable rendering of bounding boxes inside the GameBase class header, I believe.
01/10/2007 (12:28 pm)
Quote:
I can't see the bounding box, so it seems like I have to adjust values then test and keep doing that till I find the right size.
You can enable rendering of bounding boxes inside the GameBase class header, I believe.
#14
01/10/2007 (6:29 pm)
You can see the bouning box if you go into the mission editor. Spawn player, toggle editor, toggle camera. Look at the yellow lined box around the player. Edit box, rinse, repeat.
#15
01/10/2007 (6:41 pm)
You very welcome! Look in the player.cs for " datablock PlayerData(PlayerBody) "scroll down few lines to this line " boundingBox = "1.2 1.2 2.3"; ". I think is what you looking for.
#16
Thanks for all the info everyone! I've got it sorted thanks to the help here.
--Amr
01/11/2007 (3:55 am)
Cheers for that tip Zod, very useful.Thanks for all the info everyone! I've got it sorted thanks to the help here.
--Amr
Torque Owner Paul /*ilys*/ Symeou
Default Studio Name