Jump to content

animation dilema


cassius
 Share

Recommended Posts

I have coded my enemy character to follow my main character wherever it goes. If I set the mass of the enemy character to anything oyher than 0.0 it will not follow my main character up stairs.

On the other hand if I set the enemy character mass to 0.0 it WILL follow her up stairs but there is a snag. With the enemy nass set to 0.0 it floats slightly above ground level.

So neither methods are entirely satisfactory.

So whats the common practise for combining physics with animation?

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

I'm not entirely sure why, with a mass set, your NPC is not climbing the stairs. How are you moving your NPC? Is it using a character controller? Are you simply applying insufficient force to move your character? I take it if you are using a character controller that it has a suitable step height and slope angle set otherwise it wouldn't climb the stairs with the mass set to zero either!

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Just to clarify things here is what I do with characters after conversion to gmf.

 

Place character in editor

use phygen to give it a cube shaped physics body

set mass and other properties.

 

Does anyone do different to this???

such as doing the whole thing in code.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

Yeah, I would create a character controller for the characters and update it in their model scripts update method.

 

I would make a global function called GiveGlobalCharacterAttributes(obj) and call that at the start of the class script for each character passing that script object itself. Inside this function is where you could give all the attributes.

 

obj.controller = CreateController(...)

obj.health = 100

obj.etc

 

 

That way if you want to add a global attribute to all these separate character models you have 1 central place to do it. There are other ways to do this also but this is generally the "easiest"

Link to comment
Share on other sites

use phygen to give it a cube shaped physics body

set mass and other properties.

I never use phygen for characters.

The controller allready has a cylinder shaped physics body. All you have to do is to adjust it's size to your character size and then position the character mesh inside the controller cylinder. use debugphysics to view the cylinder.

Windows 7 home - 32 bits

Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM

Link to comment
Share on other sites

Ok I have set up a controller for my enemy character and it works ok exept it will not move toward my main character as it did nefore using moveentity' I also don't know what values to put in updatecontroller

 

Heres the code

 

Global barbarian_1:TModel = LoadModel("abstract::barbarian_barbarian.gmf")

Global barb_control:TController = CreateController()

PositionEntity(barb_control,EntityPosition(pos))

EntityType(barb_control, 3)

SetBodyMass(barb_control, 10.0)

SetBodyBuoyancyMode(barb_control,0)

 

Global barb_body:TBody = Createbodybox(0.6,1.9,0.6)

ScaleEntity(barb_body,Vec3(0.8,3.0,0.6))

 

EntityParent (barbarian_1,barb_control)

moveentity barb_body,vec3(0,0.3,0)

positionentity barbarian_1,EntityPosition(barb_body)

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

Seems you're still moving the body. If you are using a controller you wouldn't move the body of the model. You would move the controller and then just position your model (not body) to the position of the controller.

 

http://www.leadwerks.com/wiki/index.php?title=Controllers#UpdateController

 

Should give you a pretty good idea of moving the controller. It's been awhile since I've worked with controllers but I think you can PointEntity() on controllers. If not you can just use a pivot and then get the pivots Y value and pass that to the controllers rotation I believe. Just make the pivot follow the controller as well.

Link to comment
Share on other sites

You would move the controller and then just position your model (not body) to the position of the controller.

This is how I move my NPCs. You can make your model a child of the controller but I wouldn't recommend that as I experienced problems doing it that way. Simply apply a force and direction to the controller and get its new position; then move your model to that position as Rick is suggesting.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

This is a example taken from a simple NPC class in my (soon to be released) eki-one integration example project :

 

void npc::update(void)
{
UpdateController(m_NPCController,m_fAngleOfForce,(m_fForce),0,0,15000,1,0); 

Animate(m_entNPCModel, fmodf(AppTime()/40.0f, (float) m_iCurrentAnimationLength), 1.0f, m_iCurrentSequenceId);

PositionEntity(m_entNPCModel, EntityPosition(m_NPCController,1),1);

RotateEntity(m_entNPCModel,Vec3(0,getFacingAngle(),0),1);
}

 

In this case m_fAngleOfForce and m_fForce are derived elsewhere from a velocity vector passed from the EKI One AI engine (path finding) and the getFacingAngle() function returns the angle the NPC is currently facing; again from the AI engine.

 

In your case you would substitute these values with your own calculated (desired) values.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

At the moment I am using pointentity and moveentity but the character moves in wrong direction. I have heard that you shouldmt use moveentity with controllers but can't see any other way

Do I use PointEntity with the controller or the character or both?

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

Look at the UpdateController function. Passing your controllers to this function is how you move controllers. http://www.leadwerks.com/wiki/index.php?title=Controllers#UpdateController

 

One of the parameters to UpdateController is a rotation value. One way to point your enemy to your player is to make a pivot. Assign the position of this pivot to your controller each frame. Then use PointEntity on this pivot to your player. Then in the rotation parameter in UpdateController you can take the Y value of this pivot.

 

So basically you are rotating the pivot along it's Y rotation (as if you were just to turn around in real life) and then taking that Y rotation value and telling your controller to use it as it's rotation. You will also want to set your character model Y rotation value to the same thing each frame so your character will rotation also.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...