3D 3d animation

phillipPbor

Member
[
///animation
//KyR = keyboard_check_direct(ord("D"));//||keyboard_check_direct(ord("D"));
//KyL = -keyboard_check_direct(ord("A"));//||-keyboard_check_direct(ord("A"));
//move = KyL + KyR;

//MXSPD = move * MXSPD;

//if (move!=0) image_xscale = move;
//image_speed = 0.5;
// if place_meeting_ext(x,y,z,par_solid)
// {
// if (move!=0) sprite_index = spr_hero_run; else sprite_index = spr_hero;
// }

//if keyboard_check_direct(ord("D"))
//{sprite_index = spr_hero_run;}else{sprite_index = spr_hero;}
//if keyboard_check_direct(ord("A"))
//{sprite_index = spr_hero_run;}else{sprite_index = spr_hero;}
//if keyboard_check_direct(ord("W"))
//{sprite_index = spr_hero_runU;}else{sprite_index = spr_heroU;}
//if keyboard_check_direct(ord("S"))
//{sprite_index = spr_hero_run;}else{sprite_index = spr_hero;}

/QUOTE]



trying to make animation for the character
I tried everything.
make the player change sprite when move or jump
no matter what I tried it just wont show the animation.
 

Roa

Member
well given the sprite_index is probably not the texture used, I think we know the problem.

How are you updating the texture?
 
L

Lonewolff

Guest
I'm sure you are aware, but every line of code is commented out.

You can use standard sprites and get benefits of the normal sprite animation system in 3D, but this is dependent on how you have set everything up.

More information required.
 

phillipPbor

Member
well okay... the animation for running is left and right
the jumping is for pressing jump and falling is after you jumped
and idle for not moving
I tried the simplist basic for sprite update while moving.
and yes... there is an up/back sprite for all idal/running/jumping
upload_2019-7-3_13-43-5.pngupload_2019-7-3_13-43-40.png


its hard to describe everything. :(
 

Attachments

phillipPbor

Member
dont describe anything, give use code.


(controls) (step event)
Code:
// mouse controls
direction -= sensitivity * (display_mouse_get_x() - display_get_width() * 0.5);
pitch += sensitivity * (display_mouse_get_y() - display_get_height() * 0.5);

//limiting pitch
pitch = clamp(pitch,-80,80);

//lock mouse to center
display_mouse_set(display_get_width() * 0.5, display_get_height() * 0.5);

//keyboard cont
var FB_K = keyboard_check(ord("W")) - keyboard_check(ord("S"));
var RL_K = keyboard_check(ord("D")) - keyboard_check(ord("A"));

FB_V += FB_K * acc;
RL_V += RL_K * acc;

//limit speed
FB_V = clamp(FB_V, -MXSPD, MXSPD);
RL_V = clamp(RL_V, -MXSPD, MXSPD);

//decel if moving no keys
if (FB_K == 0 && abs(FB_V) >= acc)
{FB_V -= sign(FB_V) * acc;}

if (RL_K == 0 && abs(RL_V) >= acc)
{RL_V -= sign(RL_V) * acc;}
   
// tranlate velocite terms x y
var XV = lengthdir_x(FB_V, direction) + lengthdir_x(RL_V, direction - 90);
var YV = lengthdir_y(FB_V, direction) + lengthdir_y(RL_V, direction - 90);

// set z-vel 2 b affected by grav
if (!place_meeting_ext(x,y,z,par_solid))
    {ZV -= grav;}
   
// press SPACE to jump
if (place_meeting_ext(x,y,z-1,par_solid) && keyboard_check_pressed(vk_space)) {
    ZV += JH;
    }

//check collisions
if(XV != 00)
if(!place_meeting_ext(x+XV,y,z,par_solid))
    {x+=XV;}else{
    while (!place_meeting_ext(x+sign(XV),y,z,par_solid))
    {x+=sign(XV);}XV = 0;}
   
if(YV != 00)  
if(!place_meeting_ext(x,y+YV,z,par_solid))
    {y+=YV;}else{
    while (!place_meeting_ext(x,y+sign(YV),z,par_solid))
    {y+=sign(YV);}YV = 0;}

//Zaxes
   
if(ZV != 00)
if(!place_meeting_ext(x,y,z+ZV,par_solid)){
    z+=ZV;
    }else{
    while (!place_meeting_ext(x,y,z+sign(ZV), par_solid)){
    z += sign(ZV);
    }
    ZV = 0;
    }

//die reset 
if z < -32 {game_restart()}

(creation event)

Code:
sensitivity = 0.1;
MXSPD = 3;
acc = 0.5;
JH = 6.3; /// = jsp

FB_V = 0;
RL_V = 0;
ZV  = 0;

z = 50;
height = 16;

pitch = 0;

grav = 0.5;

mask_index = msk_player;

xmin = -6;
xmax = 6;
ymin = -6;
ymax = 6;

sprite_index=spr_hero

//grav = 0.3;
//hsp = 0;
//vsp = 0;
//jsp = 3.3;
//msp = 2;
//global.deathless = false;
//global.bossdefeat = false;
//ladder = false;

(end event)

Code:
{
  global.camx = x;
  global.camy = y;
  global.camsin = sin(direction*pi/180);
  global.camcos = cos(direction*pi/180);
}

(draw event)

Code:
  spt = sprite_index;
  if (point_distance(x,y,global.camx,global.camy) > 240) exit;
  var tex;
  tex = sprite_get_texture(spt,image_index);
  d3d_draw_wall(x-8*global.camsin,y-8*global.camcos,z+height,
                x+8*global.camsin,y+8*global.camcos,z,tex,1,1);
  draw_set_alpha_test(1);
//  draw_set_alpha_test(true);
//  draw_set_alpha_test_ref_value(128);


///background

var tex2;
tex2 = background_get_texture(BG_CLD);
d3d_draw_ellipsoid(x-420,y-420,z-420,x+420,y+420,z+420,tex2,6,6,16);

(animation) (step event)

Code:
///animation

//KyR =  keyboard_check_direct(ord("D"));//||keyboard_check_direct(ord("D"));
//KyL = -keyboard_check_direct(ord("A"));//||-keyboard_check_direct(ord("A"));

//move = KyL + KyR;
 
//MXSPD = move * MXSPD;


//if (move!=0) image_xscale = move;
//image_speed = 0.5;
//    if place_meeting_ext(x,y,z,par_solid)
//    {
//        if (move!=0) sprite_index = spr_hero_run; else sprite_index = spr_hero;
//    }


if keyboard_check_direct(ord("D"))
{sprite_index = spr_hero_run;}else{sprite_index = spr_hero;}

if keyboard_check_direct(ord("A"))
{sprite_index = spr_hero_run;}else{sprite_index = spr_hero;}

if keyboard_check_direct(ord("W"))
{sprite_index = spr_hero_runU;}else{sprite_index = spr_heroU;}

if keyboard_check_direct(ord("S"))
{sprite_index = spr_hero_run;}else{sprite_index = spr_hero;}
that's the entire code for the player

the entire code is based off of the tutoriels from Tristan batchler

I wanted to make a 3d platformer advanture game

FSI helped me with a code for the collision events.
 

Yal

šŸ§ *penguin noises*
GMC Elder
When you have multiple if-else statements chained together like this whichever else is last will always win. Change your code to this instead:
Code:
sprite_index = spr_hero;
if keyboard_check_direct(ord("D"))
{sprite_index = spr_hero_run;}

if keyboard_check_direct(ord("A"))
{sprite_index = spr_hero_run;}

if keyboard_check_direct(ord("W"))
{sprite_index = spr_hero_runU;}

if keyboard_check_direct(ord("S"))
{sprite_index = spr_hero_run;}
 

phillipPbor

Member
When you have multiple if-else statements chained together like this whichever else is last will always win. Change your code to this instead:
Code:
sprite_index = spr_hero;
if keyboard_check_direct(ord("D"))
{sprite_index = spr_hero_run;}

if keyboard_check_direct(ord("A"))
{sprite_index = spr_hero_run;}

if keyboard_check_direct(ord("W"))
{sprite_index = spr_hero_runU;}

if keyboard_check_direct(ord("S"))
{sprite_index = spr_hero_run;}



i did what you have tole, I posted them in step events... like this?
 
Top