detecting if a player has "stepped" ?

Blitz3D Forums/Blitz3D Programming/detecting if a player has "stepped" ?

Guy Fawkes(Posted 2010) [#1]
how would i detect if the foot of the player has hit the ground?


FlagDKT(Posted 2010) [#2]
foot_bone=findchild charMesh,"leftFoot"
collPivot=createPivot(foot_bone)
Entitytype collPivot,colltype
EntityRadius collPivot,radius#

check for collPivot blitz collision with the ground Surface (using CollisionSurface etc..)

btw I don't think it's a wise thing..


_PJ_(Posted 2010) [#3]
I'm gonna take a wild guess (as well as noting your other post about the animation sequences/time) that this is perhaps due to wanting to synchronise footstep sounds with the placement of the foot(or feet) on the ground?

It would make sense that you have some frame limiting or timing tehnique to ensure a single 'walk' sequence will always take the same time.
All you need to do, is sync the playing of two footsteps one with the duration/2 and another at the duration.

This also assuems you cancel the animation (switch to, say, 'idle') if the player stops walking halfway through.

It's much more efficient to have the sound played every x seconds than to constantly check the positions and collisions.


Ross C(Posted 2010) [#4]
What i would do, is check the animtime command (which is actually the current frame) Visually, check which frames the players feet hit the ground, and play the sound.


Guy Fawkes(Posted 2010) [#5]
yes, i wanna synchro the footsteps when the feet touch the ground.

so far, here is what i have:




GIB3D(Posted 2010) [#6]
You could attach Pivots to the feet bones using FindChild(entity,"Left_Foot") then put the collisions on the pivot.


Guy Fawkes(Posted 2010) [#7]
i like that idea much better


Naughty Alien(Posted 2010) [#8]
..collision for footsteps is very wrong idea..checking specific frame is much more better and faster, as Ross already mentioned..


Guy Fawkes(Posted 2010) [#9]
i dont care if its a LITTLE slow. sheesh. im not trying to make a state-of-the-art game. i only care if its fast enough to run on windows 98 & up


_PJ_(Posted 2010) [#10]
The operating system is mostly irrelevant.

Checking through the ENTIRE collision table every loop for just the footsteps is gonna be intensive, especially since you haven't even exited the loop after a positive result.
It would probably make more sene to combiine the collision event checks in the loop so you don't need to make multiple checks.

If you're not bothered about the efficiency of your code, then does this mean we wont see posts about "low framerates" or "why is my game so slow?"

Efficiency of the codeis even more crucial if you're not using state-of-the-art techniques to minimise overheads and manage resources.


Guy Fawkes(Posted 2010) [#11]
i never said that. i said i simply want it to run not VERY fast, but fast enough for a player to play around 40-60 fps on a windows 98 or higher


Drak(Posted 2010) [#12]
I would advise against NOT checking for positive collision between a foot and the ground. Why? Because unless you have some switch or flag to flip, the collision may trigger say 15 or 20 frames in a row, creating a machine-gun footstep effect. What about when the player is standing still? 2 positive collisions between both feet and the ground = 2 constant machine-gunning sound effects. To make that work you'll have to only check for collisions until a collision is detected, then say don't check again until x frames of walk animation again... or something... anyway it'll get way complicated.

Ross C's idea is much, much simpler than the collision method. However, you will still have to have a switch or flag to not play the sound while the player is standing still. Alternatively, I guess you would only need to check it while the player is animating in the walk\run cycle.


Leon Drake(Posted 2010) [#13]
If it were me i would just record which frames in the animation a players foot touches the ground and play the footstep at that moment.


Guy Fawkes(Posted 2010) [#14]
ive decided im just going to attach very small invisible spheres to the feet, and detect if they collide


GIB3D(Posted 2010) [#15]
Sounds good to me. There's always more than one way to do everything :)


Guy Fawkes(Posted 2010) [#16]
Indeed ^^


Drak(Posted 2010) [#17]
This will trigger the footstep to fire, but I'll tell you right now that it may trigger the sound for many more than 1 single frame. The foot will more than likely be colliding with the ground, or terrain, or whatever, for say 5 or 8 frames before being lifted again, and that will trigger the footstep sound 5 or 8 frames in a row. What that will do is turn your step sound into RATATATATATATSTEP. You'll have to code the sound to play only once every animation cycle.


GIB3D(Posted 2010) [#18]
Don't worry, if that happens then you'll know why more threads are created by Rez about "repeated sound glitch".


Naughty Alien(Posted 2010) [#19]
..thats why I have suggested simple frame check..works like a charm and no issues such as sound repetition..


Drak(Posted 2010) [#20]
I agree with Naughty Alien.


Guy Fawkes(Posted 2010) [#21]
ok, how would u do a frame check?

frame = frame + 1 or something? idk, ive never seen this type of code


Naughty Alien(Posted 2010) [#22]
something like this

if frame_playing_from_my_current_sequence = one_of_the_Stored_frames_for_current_sequence 
  emitsound(my_footstep_sound)
end if


something like this...


Ross C(Posted 2010) [#23]
animtime command gives you the current frame.


Guy Fawkes(Posted 2010) [#24]
ok cool