Gun Recoil Animation

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Gun Recoil Animation

Post by disanti »

Code: Select all

	if(recoil)
	{
		droid.guns[droid.gunID]->setCurrentFrame(1);

		//play gun's recoil animation
		if(droid.guns[droid.gunID]->getFrameNr() >= 19)
		{
			recoil = false;
		}
	}
	else
	{
		droid.guns[droid.gunID]->setCurrentFrame(19);
	}
Why, NO MATTER WHAT, does the animation ALWAYS loop? :? I'm loading a gun from a X file and it plays its animation endlessly. Even if I set the current frame of the animation. How do I make it stop?
________
Michigan medical marijuana dispensaries
Last edited by disanti on Tue Feb 22, 2011 8:05 am, edited 1 time in total.
isiahil

Post by isiahil »

After setting recoil=false set the fram to 19.
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

The animation is still looping. That made absolutely no difference.
________
Yamaha Music Foundation History
Last edited by disanti on Tue Feb 22, 2011 8:05 am, edited 1 time in total.
pex
Posts: 16
Joined: Sun Mar 28, 2004 11:51 am

Post by pex »

i dont understand in frames much, like setFrameNr..
but have you tried setFrameLoop=false;?
and i think that when the frame is >=19, recoil becomes false but the loop is still true. so maybe thats the problem.
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

Niko, how do I do this? Pex... your solution gives an error. You cannot tell a function that it is false! :roll:

There must be a way to stop the darn animation!!! :evil:
________
Digital vaporizer
Last edited by disanti on Tue Feb 22, 2011 8:06 am, edited 1 time in total.
Mercior
Posts: 100
Joined: Tue Feb 24, 2004 1:53 am
Location: UK
Contact:

Post by Mercior »

You're only setting the frame number, it is going to carry on playing the same sequence (and looping it) until you use setFrameLoop()
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

Ok, I couldn't get that to work so now I'm using a new method. I'm trying to change the animation of the x file altogether (now it has 2 animations).

How do I do this? :oops:

Code:

//load the normal animation
gunanim[0] = gProc.smgr->getMesh(".\\data\\gun1\\gun1.x");
if(gunanim[0])
{
guns[0] = gProc.smgr->addAnimatedMeshSceneNode(gunanim[0],cam,-1);
guns[0]->setVisible(false);
}

Error:
d:\pss4086new\source\player.cpp(6) : error C2440: '=' : cannot convert from 'class irr::scene::IAnimatedMesh *' to 'class irr::scene::IAnimatedMeshX *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Have I done something wrong?
________
JUGGALO
Last edited by disanti on Tue Feb 22, 2011 8:06 am, edited 1 time in total.
Coolkat
Posts: 25
Joined: Sun Mar 28, 2004 1:44 am
Location: U.S.A.

Post by Coolkat »

it seems you are sending a certain class type to the function in a param that wants a different class. you cold either change the class type or typecast your code.. example..

(im assuming that gunanim[0] is the pointer to the class)

Code: Select all

guns[0] = gProc.smgr->addAnimatedMeshSceneNode((irr::scene::IAnimatedMeshX *)gunanim[0],cam,-1); 
guns[0]->setVisible(false);
that should work.. or when you made the variable make it

Code: Select all

irr::scene::IAnimatedMeshX *gunanim[];
i believe you need to use the X at the end because it is a different class to handle .x files. please correct me if im wrong.
IcePump Gaming
under construction
Post Reply