3d zelda based game

Posted By: Dega

3d zelda based game - 08/11/12 20:48

I am trying to make a game where you are a guy with a sword that swings around in front of the characters hand. I cannot figure out how to create the sword at the right spot(the players hand) and follow the player's pan while it is not deleted yet. May I have some tips or example with this code? I really don't know where to start.
Code:
action sword()
{
	var percent;
	var sword_life_timer = 10;

	while(1)
	{
		percent += 0;
		ent_animate(player,"atk",percent,NULL);
		sword_life_timer -= 1 * time_step;
		if (sword_life_timer <= 0)
		{
			ent_remove(me);
			return;
		}
		wait(1);
	} 
}


Posted By: Reconnoiter

Re: 3d zelda based game - 08/12/12 10:16

I am still bit of a novice, but this should do the trick
Code:
vec_for_bone(VECTOR*,ENTITY*,STRING* name)

for positioning e.g. weapons in the players hand.
If your Zelda model has bones, you can use the code below:

Code:
action sword()
{
        VECTOR bone_attach;
	var percent;
	var sword_life_timer = 10;

	while(1)
	{
                vec_for_bone(bone_attach,player, "BoneRightArm"); // in MDL editor, rename the bone of the model's right arm to "BoneRightArm"
	        my.pan = player.pan;
		percent += 0;
		ent_animate(player,"atk",percent,NULL);
		sword_life_timer -= 1 * time_step;
		if (sword_life_timer <= 0)
		{
			ent_remove(me);
			return;
		}
		wait(1);
	} 
}


If you dont know about bones, you should learn about them, it is very handy (see Lite-C Workshop 23: Bones).
Posted By: Dega

Re: 3d zelda based game - 08/12/12 20:35

That didnt work. However it got me on the right track for accomplishing it. So thank you very much and for a newbie like me that was very impressive! I think I am figuring it out!
Posted By: Nowherebrain

Re: 3d zelda based game - 08/12/12 21:31

a very simple trick is to animate the sword with the player....other than that you can attach the sword to a vertex and align it along another vertex(or vertexes...roll and tilt)...this is provided you have the vertexes to work with, pre-meditated ....but as you seem new to coding in general, or just 3dgs, I recommend animating it with the player. Then just copy the players coords and pan to the sword every frame and you're good to go.
© 2024 lite-C Forums