animation affecting game code

Blitz3D Forums/Blitz3D Beginners Area/animation affecting game code

sec05(Posted 2004) [#1]
Hi there,

I used biped animation in max and following a tutorial I found on the net, I exported it as a SMD format, and exported it out as a b3d format in milkshape.

The problem is my code no longer works. Here's a snip of my code:

Global gravity#

; loads the environment and my animated character
scene = LoadAnimMesh("env.b3d")
player = LoadAnimMesh("player.b3d")

ScaleEntity player, 0.5, 0.5, 0.5
PositionEntity player, 0, -77, 0
EntityType player, type_player
EntityRadius player, 2, 7.5

; ground is a plane in my scene
ground = FindChild(scene, "ground")
EntityType ground, type_ground

; setups collision
Collisions type_player, type_ground, 2, 3

While Not KeyHit(1)
gravity# = gravity# - .08

If EntityCollided(player, type_ground) Then
gravity# = 0
EndIf

TranslateEntity player, 0, gravity#, 0

UpdateWorld
RenderWorld

Flip

Wend

End

I try applying simple gravity to my player but the problem is when the game loads, the character just fell through the ground.

I also tried using the FindChild command to refer to my player (works for bones animation though if I use the FindChild command, but it doesn't seem to work for biped) but when the game loads, it returns with a memory access violation.

Anyone knows why?


TomToad(Posted 2004) [#2]
I assume somewhere near the beginning of your program you define what values type_ground and type_player are?

I haven't messed much with 3D animation as of yet, but on a couple of projects I found it easiest to create a pivot, then parent the animated entity to the pivot, then do all my movement, collisions, etc... on the pivot.


CodeOrc(Posted 2004) [#3]
In addition to what TomToad said, I do not see the;

ExtractAnimSeq(player_model,x,x)
or the
Animate player_model,x

I have to use both of those in my code or my anim's do not work. I export my models from MAX as B3D using the MAX>B3D Pipeline.

Hope that helps.


Duckstab[o](Posted 2004) [#4]
you need to assign a value above zero to entity types

try adding
global type_player=1
global type_ground=2

each entity group needs it own entitytype eg different value

btw collisions is only relative to the moving entity

Collisions type_player, type_ground, 2, 3
will only check if entity player hit entity ground
and not vice verser

add a reversed set if checking 2 entitys for collision
eg Collisions type_player2, type_player1, 2, 3
eg Collisions type_player1, type_player2, 2, 3
not forgetting to do globals at start of code :)

this also lets you work out who hit who o/


sec05(Posted 2004) [#5]
Hi, thanks for the reply.

The problem is when I use a 3ds file (using bones in max to animate) there is collision happening.

When I change the file format to b3d (using biped) it never have collision.