Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
help with animation sounds #139004
07/01/07 03:45
07/01/07 03:45
Joined: Jul 2007
Posts: 3
J
jrg Offline OP
Guest
jrg  Offline OP
Guest
J

Joined: Jul 2007
Posts: 3
I used the Au Magazine camera code and changed it up a bit. I want my character to
make a sound each time a foot touches the floor. I have no idea on where to start.

Code:
 //////////////////////////////////////////////////////////////

var video_mode = 7; // 800x600 pixels
var video_depth = 32; // 32 bit mode
var video_screen = 1; // start the engine in full screen mode

////////////////////////////////////////////////////////////////////////////////////

string work28_wmb = <chartest.wmb>;
////////////////////////////////////////////////////////////////////////////////////

function isometric_camera();


////////////////////////////////////////////////////////////////////////////////////

function main()
{
level_load (work28_wmb);
wait (3); // wait until the level is loaded
// call the desired camera function here
isometric_camera();
walk_sounds();
}


function isometric_camera() // displays the player from an isometric view aka 3rd person view
{
while (player == null) {wait (1);} // wait until the player is created
camera.tilt = -15; // look down at the player, play with this value
while (1)
{
camera.x = player.x - 150 * cos(player.pan); // 250 = distance between the player and the camera, play with this value
camera.y = player.y - 150 * sin(player.pan); // use the same value here
camera.z = player.z + 80; // place the camera above the player, play with this value
camera.pan = player.pan; // the camera and the player have the same pan angle
wait (1);
}
}

function walk_sounds()
{
if ((key_w == 1))
{ wait(60);
ent_playsound(me,thud,60);
}
}

starter tunes()
{
var current_track = 1;

while (1)
{

if (current_track == 1)
{
media_play("TOFTIM.wav", null, 100);
}

while (snd_playing(media_handle) != 1) {wait (1);}
sleep (1);
}
}
action players_code
{
var anim_percentage; // animation percentage
var movement_speed; // player's movement speed
var distance_to_ground; // the distance between player's origin and the ground
player = my; // I'm the player
while (1)
{

my.pan += 6 * (key_a - key_d) * time; // rotate the player using the "A" and "D" keys
vec_set (temp.x, my.x); // copy player's position to temp
temp.z -= 5000; // set temp.z 5000 quants below player's origin
distance_to_ground = c_trace (my.x, temp.x, ignore_me | use_box);
movement_speed.x = 9 * (key_w - key_s) * time; // move the player using "W" and "S"
movement_speed.y = 0; // don't move sideways
movement_speed.z = - (distance_to_ground - 17); // 17 = experimental value
movement_speed.z = max (-35 * time, movement_speed.z); // 35 = falling speed
c_move (my, movement_speed.x, nullvector, glide); // move the player
if ((key_w == off) && (key_s == off)) // the player isn't moving?
{
ent_animate(my, "stand", anim_percentage, anm_cycle); // play the "stand" animation
}
else // the player is moving?
{
ent_animate(my, "walk", anim_percentage, anm_cycle); // play the "walk" animation
}
anim_percentage += 10 * time; // 5 = animation speed
if(MY.frame == "walk2") { ent_playsound(ME,thud,60); }


wait (1);
}
}



If anyone can help me with this please respond.


Newb...
Re: help with animation sounds [Re: jrg] #139005
07/01/07 06:59
07/01/07 06:59
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
f.e. you can do it with vec_for_vertex function + c_trace function in loop.

so if vertex (on the bottom of the heel) touches the ground (result of c_trace from this vertex to the ground is small), play sound.

Simple code
Code:
 
var heel_p[3]; var heel_l[3];
sound foot_step = <step.wav>;

function walk_sound
{
while(me)
{
//right foot
vec_for_vertex(heel_p,me,150); //check what vertex is correct to your model
temp.x = heel_p.x;
temp.y = heel_p.y;
temp.z = -500;
c_trace(heel_p,temp,ignore_me);
if(result <=2) //play with this value
{
if ((key_w == 1) || (key_s == 1)) //play sound only when walking
{
ent_playsound (me, foot_step, 200); //play with 200
}
}

//left_foot
vec_for_vertex(heel_l,me,100);
temp.x = heel_l.x;
temp.y = heel_l.y;
temp.z = -500;
c_trace(heel_l,temp,ignore_me);
if(result <=2)
{
if ((key_w == 1) || (key_s == 1)) //play sound only when walking
{
ent_playsound (me, foot_step, 200); //play with 200
}
}
wait(1);
}
}



You can add to c_trace scan_texture mode, to check what kind of floor is below the entity.
if (str_cmpi(tex_name,"grass")==1){play grass.wav}; etc


Simplest way:
You can do this checking animation percentage or frame number.
Check in med in which frame your model put the heel on the ground an then
if(my.frame == 10) || (my.frame == 20){play sound;}

Cheers

Last edited by tompo; 07/01/07 07:21.
Re: help with animation sounds [Re: tompo] #139006
07/01/07 17:52
07/01/07 17:52
Joined: Jul 2007
Posts: 3
J
jrg Offline OP
Guest
jrg  Offline OP
Guest
J

Joined: Jul 2007
Posts: 3
Thank you very much


Newb...
Re: help with animation sounds [Re: jrg] #139007
07/01/07 22:05
07/01/07 22:05
Joined: Jul 2007
Posts: 3
J
jrg Offline OP
Guest
jrg  Offline OP
Guest
J

Joined: Jul 2007
Posts: 3
I have updated the code but still no sound , maybe i am using the "if" function wrong?

code:

//////////////////////////////////////////////////////////////

var video_mode = 7; // 800x600 pixels
var video_depth = 32; // 32 bit mode
var video_screen = 1; // start the engine in full screen mode

////////////////////////////////////////////////////////////////////////////////////

string work28_wmb = <chartest.wmb>;
SOUND tap2 = <tap.wav>;
////////////////////////////////////////////////////////////////////////////////////

function isometric_camera();


////////////////////////////////////////////////////////////////////////////////////

function main()
{
level_load (work28_wmb);
wait (3); // wait until the level is loaded
// call the desired camera function here
isometric_camera();

}



function isometric_camera() // displays the player from an isometric view aka 3rd person view
{
while (player == null) {wait (1);} // wait until the player is created
camera.tilt = -15; // look down at the player, play with this value
while (1)
{
camera.x = player.x - 150 * cos(player.pan); // 250 = distance between the player and the camera, play with this value
camera.y = player.y - 150 * sin(player.pan); // use the same value here
camera.z = player.z + 80; // place the camera above the player, play with this value
camera.pan = player.pan; // the camera and the player have the same pan angle
wait (1);
}
}


starter tunes()
{
var current_track = 1;

while (1)
{

if (current_track == 1)
{
media_play("TOFTIM.wav", null, 20);
}

while (snd_playing(media_handle) != 1) {wait (1);}
sleep (1);
}
}
action players_code
{
var anim_percentage; // animation percentage
var movement_speed; // player's movement speed
var distance_to_ground; // the distance between player's origin and the ground
player = my; // I'm the player

while (1)
{

my.pan += 6 * (key_a - key_d) * time; // rotate the player using the "A" and "D" keys
vec_set (temp.x, my.x); // copy player's position to temp
temp.z -= 5000; // set temp.z 5000 quants below player's origin
distance_to_ground = c_trace (my.x, temp.x, ignore_me | use_box);
movement_speed.x = 9 * (key_w - key_s) * time; // move the player using "W" and "S"
movement_speed.y = 0; // don't move sideways
movement_speed.z = - (distance_to_ground - 17); // 17 = experimental value
movement_speed.z = max (-35 * time, movement_speed.z); // 35 = falling speed
c_move (my, movement_speed.x, nullvector, glide); // move the player
if ((key_w == off) && (key_s == off)) // the player isn't moving?
{
ent_animate(my, "stand", anim_percentage, anm_cycle); // play the "stand" animation
}

else // the player is moving?
{
ent_animate(my, "walk", anim_percentage, anm_cycle); // play the "walk" animation
}

anim_percentage += 10 * time; // 5 = animation speed

if(my.frame == 4) { ent_playsound(me,tap2,100);}

wait (1);
}
}

code:


Newb...

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1