how to... drop the enemy when he is dead ?
how to... drop the enemy when he is dead ?
hi !
video: http://www.youtube.com/watch?v=zDfO7p64K5E
i'm testing some of AI, and attacks by the enemy, and by me player. but what can i do, when my enemy is dead ?
i'm thinking of moving the enemy to a position far far away.
example, i'm killing my enemy at (0,0,0) but when he is dead, the screen show the message victory for ... 5 seconds ? and then the enemy position change, to ( 0,-500000,0 )
works ?
or suggest me something (:
i'm trying to drop the enemy node, but the program crash !
moving to a far far far away position ?
-greetings
video: http://www.youtube.com/watch?v=zDfO7p64K5E
i'm testing some of AI, and attacks by the enemy, and by me player. but what can i do, when my enemy is dead ?
i'm thinking of moving the enemy to a position far far away.
example, i'm killing my enemy at (0,0,0) but when he is dead, the screen show the message victory for ... 5 seconds ? and then the enemy position change, to ( 0,-500000,0 )
works ?
or suggest me something (:
i'm trying to drop the enemy node, but the program crash !
moving to a far far far away position ?
-greetings
my first app with irrlicht http://youtube.com/watch?v=8OHUgciBT8E
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
Try calling remove() on the node instead of drop(). Also, check to make sure you don't have a pointer to that node somewhere else.
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
let me try with other simple project, in this, everytime that i call drop or remove to try to drop a node, the program crash.
this is the problem to take me to thinking to set the position node far away.
this is the problem to take me to thinking to set the position node far away.
my first app with irrlicht http://youtube.com/watch?v=8OHUgciBT8E
Maybe try to use addToDeletionQueue:
Code: Select all
//! Adds a scene node to the deletion queue.
/** The scene node is immediatly
deleted when it's secure. Which means when the scene node does not
execute animators and things like that. This method is for example
used for deleting scene nodes by their scene node animators. In
most other cases, a ISceneNode::remove() call is enough, using this
deletion queue is not necessary.
See ISceneManager::createDeleteAnimator() for details.
\param node: Node to detete. */
virtual void addToDeletionQueue(ISceneNode* node) = 0;
Since the scene manager has the ownership over the scene node, and hence expects it "to be there", you're not supposed to drop it (unless you've grab()bed it before).
So, either do a
as 3DModelerMan supposes, or even safer as greenya shows in his post.
So, either do a
Code: Select all
yourSceneNode->remove();
beer->setMotivationCallback(this);
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
If you want to play the animation. You could also just start the animation playing. And add a deletion animator for the time that the animation takes.
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
yes, if you see the video of my first post, i have the animation done to the killed enemy.
but still i having problems with remove , drop, or addtodeletionQueue
for now, when the enemy is dead, i set the position how i say at first time, far away. i know this is not the best way D: !!!
someone can make me a simple example, with remove a node ?
here the code that i'm trying, some basic to trying remove
but the programa crash !!!
but still i having problems with remove , drop, or addtodeletionQueue
for now, when the enemy is dead, i set the position how i say at first time, far away. i know this is not the best way D: !!!
someone can make me a simple example, with remove a node ?
here the code that i'm trying, some basic to trying remove
Code: Select all
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(lib, "Irrlicht.lib")
#endif
#include <irrlicht.h>
#include "driverChoice.h"
using namespace irr;
int timing=500;
int main(){
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT) return 1;
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<u32>(640, 480), 16, false, false, false, 0);
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
scene::IAnimatedMeshSceneNode* cofre = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/enemy.ms3d"));
if (cofre) {
cofre->setMaterialFlag(video::EMF_LIGHTING, false);}
smgr->addCameraSceneNodeFPS();
while(device->run()){
driver->beginScene(true, true, video::SColor(255,255,0,0));
timing -= 1;
if (timing < 0){
cofre->remove();
}
smgr->drawAll();
driver->endScene();}
device->drop();
return 0;
}
my first app with irrlicht http://youtube.com/watch?v=8OHUgciBT8E
-
- Posts: 1215
- Joined: Tue Jan 09, 2007 7:03 pm
- Location: Leuven, Belgium
You keep on removing the node every frame after the timer has decreased, meaning that as soon as the timer hits -2 (with the node actually removed at -1) it will try to remove a non-existing node, causing the crash
Also it's not a good idea to base a timer on your framerate, unless you use vsync or some other syncing method
Also it's not a good idea to base a timer on your framerate, unless you use vsync or some other syncing method
oh thanks, i dont know how i didn't see that
i change to if timing == 0
cofre ->remove
and works !
well, i'm using a variable, when the life enemy is 0 , the variable is true, and the node will remove it.
i change to if timing == 0
cofre ->remove
and works !
well, i'm using a variable, when the life enemy is 0 , the variable is true, and the node will remove it.
my first app with irrlicht http://youtube.com/watch?v=8OHUgciBT8E
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
A better way than "timing == 0" would be:
That way if you ever change timing to a float, and actually calculate a delta time, and zero gets skipped it'll still work.
Code: Select all
if (timing < 0 && cofre != 0)
{
cofre->remove();
cofre = 0;
}
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Better would be to check the other way round3DModelerMan wrote:A better way than "timing == 0" would be:Code: Select all
if (timing < 0 && cofre != 0) { cofre->remove(); cofre = 0; }
Code: Select all
if (cofre && timing < 0)
{
cofre->remove();
cofre = 0;
}
Even better would be to get rid of this poop and do it like real men, i.e. with a message/signal system.
http://www.boost.org/doc/libs/1_46_0/do ... gnals.html
"Whoops..."
thanks for the answers !!!! are very usuful !
my first app with irrlicht http://youtube.com/watch?v=8OHUgciBT8E
update VIDEO:
http://www.youtube.com/watch?v=wejkccdIXuQ
now i can remove an enemy !!
a simple test, but works thanks !
now i have to make better animation to the models and some particle effects to the die.
now i'm working on collisions.
what psyhic engine recommend me ?
-greetings !
http://www.youtube.com/watch?v=wejkccdIXuQ
now i can remove an enemy !!
a simple test, but works thanks !
now i have to make better animation to the models and some particle effects to the die.
now i'm working on collisions.
what psyhic engine recommend me ?
-greetings !
my first app with irrlicht http://youtube.com/watch?v=8OHUgciBT8E
irrlicht has a built in collision detection, may you want to try that first?paulorr29 wrote: what psyhic engine recommend me ?
http://irrlicht.sourceforge.net/tut007.html
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=43066
otherwise it is like the question, "i am new to driving which branch of car you reccommend..."
Newton, Physx, Bullet, Havoc and ODE are the common choices.
which one you use belongs to which implementation is easier to use with your knowledge and which kind of license you would preffer, there are wrappers and users for each of them here.