I'm trying to avoid using animators, mostly because i don't want to go
through another layer of functions and i'm a total newbie at working with
irrlicht and they confuse the hell out of me at the moment.
so i'm really lost for ways to move scene nodes
without the if ( node ){ blah } thing, when i try
to use that in my object's step method. it crashes
the project D:
any help will be greatly appreciated
Manipulating scene nodes?
-
- Posts: 1215
- Joined: Tue Jan 09, 2007 7:03 pm
- Location: Leuven, Belgium
Re: Manipulating scene nodes?
My advice would be to just take the step and learn how to use them, they're a really great tool for manipulating nodes without having to resort to hacks like animating nodes directly in your rendering loopprodcake wrote:I'm trying to avoid using animators, mostly because i don't want to go
through another layer of functions and i'm a total newbie at working with
irrlicht and they confuse the hell out of me at the moment.
Also 'it crashes the project' doesn't give us enough information on what you want to accomplish and where it went wrong, please post what you're trying to do exactly with the code you're using, and post any error codes or crash reports
Code: Select all
class Footsoldier:Soldier
{
public:
int Hp;
bool Dead;
bool canshoot;
IAnimatedMeshSceneNode* node;
vector3df pos;
vector3df rot;
void Step();
void Start()
{
IAnimatedMesh* mesh = smgr->getMesh("media/soldier.x");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
srand ( time(NULL) );
X=rand()%20 - 10;
Z=rand()%20 - 10;
pos.X = X;
pos.Y = 0;
pos.Z = Z;
rot.Y = ( rand()%360 );
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMaterialTexture( 0, driver->getTexture("media/soldier.png") ) ;
node->setFrameLoop(0,25);
node->setPosition(pos);
node->setRotation(rot);
}
};
// Step
};
void Footsoldier::Step()
{
if (node)
{
pos.X += 3;
node->setPosition(pos);
}
};
obviously i shouldn't be using two "if (node)"'s because
this is what causes the crash in my project, I just don't
know how to set the position any other way, I'm still
studying the irrlicht manual and the examples at the
moment, and i don't know a way to change the exact
position without using node->setPosition(pos);
it compiles fine and when it runs it crashes
exception code c0000005
Code: Select all
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
Replace it with
so the "node" inside Step() would refer to the same variable.
Code: Select all
node = smgr->addAnimatedMeshSceneNode( mesh );
You look more like newbie to c++, you should study more of it if you want to work with irrlicht.prodcake wrote:Like i said, i'm a newbie at using irrlicht. so could you at least extrapolate a bit more? because just saying that alone isn't much.
but thank you anyway
Working on game: Marrbles (Currently stopped).