Problem using a shapebase inherited class as player
by Benj · in Torque Game Engine · 07/16/2007 (8:36 am) · 12 replies
Ive been trying to make my own class on the c++ side that inherits from shapebase like player does, a sort of simple tank class, i got it to load and render, but when i replace
i start getting access violations when it tried to settransform it, so i tell it not to settransform it, and i start getting access violations in the terrain renderer....
is there something im missing to properly inherit from shapebase, right now thats all its doing...
like this
but if i just change Player to ShapeBase instead of Tank it doesnt crash,.... so strange.
// Create the player object
%player = new Player() {
dataBlock = PlayerBody;
client = %this;
};with// Create the player object
%player = new Tank() {
dataBlock = thetank;
client = %this;
};i start getting access violations when it tried to settransform it, so i tell it not to settransform it, and i start getting access violations in the terrain renderer....
is there something im missing to properly inherit from shapebase, right now thats all its doing...
like this
class Tank: public ShapeBase
{
typedef ShapeBase Parent;
public:
DECLARE_CONOBJECT(Tank);
Tank();
bool onAdd();
void onRemove();
void processTick(const Move* move);
};but if i just change Player to ShapeBase instead of Tank it doesnt crash,.... so strange.
About the author
#2
it works fine if i go ingame with kork, and spawn one, and setcontrolobject it, but when the game does it automatically it has the access violation issues...
07/16/2007 (9:06 am)
In the cc file yesIMPLEMENT_CO_NETOBJECT_V1(Tank);
Tank::Tank()
{
mTypeMask |= PlayerObjectType;
}
bool Tank::onAdd()
{
if (!Parent::onAdd())
return false;
addToScene();
if (isServerObject())
{
scriptOnAdd();
}
return true;
}
void Tank::onRemove()
{
scriptOnRemove();
removeFromScene();
Parent::onRemove();
}it works fine if i go ingame with kork, and spawn one, and setcontrolobject it, but when the game does it automatically it has the access violation issues...
#3
This flag will tell all sorts of systems that it's fine to treat your tank as if it were of the Player class, which it isn't.
07/16/2007 (5:57 pm)
mTypeMask |= PlayerObjectType;
This flag will tell all sorts of systems that it's fine to treat your tank as if it were of the Player class, which it isn't.
#4
07/16/2007 (6:35 pm)
I did that for collisions and such, anyway, i changed that to shapebaseobjecttype and it still crashes before even getting ingame :/
#5
07/18/2007 (8:11 am)
Does anyone have any ideas? im wanting to make a simple tank game and moding the player class would be more work then just making a tank class, but i cant get it to stop crashing....
#6
07/18/2007 (8:22 am)
Have you looked at using the Vehicle class instead ?
#7
I would highly suggest using your IDE to track the crashes, inspect the call stack, and determine through troubleshooting and code inspection what your issues are.
07/18/2007 (8:22 am)
We can't really guess at what your issue(s) may be without basically seeing all of your code, and having access to a project that has your code built in. (Note: I am not suggesting you post your entire class! You need to do some debugging is all).I would highly suggest using your IDE to track the crashes, inspect the call stack, and determine through troubleshooting and code inspection what your issues are.
#8
i did post my entire class a few posts up. i tried tracking it down but, depending on what lines i commented out in createplayer in game.cs it would crash in totally random places, like terrain rendering.
ah, looks like the problem was in a part i forgot to post lol
the last 2 lines before the } seem to crash it... not sure why. but at least it works now.
07/18/2007 (12:01 pm)
Theres no vehicle that would do tank style movement well.i did post my entire class a few posts up. i tried tracking it down but, depending on what lines i commented out in createplayer in game.cs it would crash in totally random places, like terrain rendering.
ah, looks like the problem was in a part i forgot to post lol
void Tank::processTick(const Move* move)
{
if(!move)
return;
mCurPos += Point3F(move->x,move->y,0);
setPosition(mCurPos);
}the last 2 lines before the } seem to crash it... not sure why. but at least it works now.
#9
07/20/2007 (8:06 am)
Now my problem is settransform wont work on it.... it may load correctly as the player but i end up at 0,0,0, yet if i gettransform it it says im at the correct location to be on the terrain.... :/
#10
07/20/2007 (8:09 am)
You have no networking code for your object (other than stock GameBase's code), no physics, and no interpolation/extrapolation.
#11
07/20/2007 (8:14 am)
Ya i got alot of work todo on it... :/ i wish one of the vehicle classes was able to be tweaked enough to act like a tank. turn style and all. and this is off shapebase not gamebase.
#12
07/20/2007 (8:07 pm)
Orion Elenzil: what is just a clean vehicle like.. does it have any movement to it or is all that added by hover/flying etc, i cant get just a vehicle to load to test it.
Associate Ian Omroth Hardingham