Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (AndrewAMD, Ayumi, NewbieZorro), 14,141 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Script issue #309465
02/09/10 15:31
02/09/10 15:31
Joined: Oct 2009
Posts: 60
T
Tman Offline OP
Junior Member
Tman  Offline OP
Junior Member
T

Joined: Oct 2009
Posts: 60
Hello forum,
I am new here and was needing some help with code, first let me say this is a really good engine to work with. The issue that I am having is gravity for starters, I have the line commented out for jump because everytime I jump I just keep going, and second this may be an animation issue but I press a certain button to change states and it doesn't play the animation, any help would be appreciated thanks guys.
Here is the code:



Code:
#include  <acknex.h>
#include  <default.c>

#define STATE     skill1
#define ANIMATION skill2
#include "defines.c"
//#include "animation.c"

function camera_follow(ENTITY* ent)
{
	while(1) 
	{
		vec_set(camera.x,vector(-250,10,50));  // camera position relative to the player      
		vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
		vec_add(camera.x,ent.x);      // add player position
		vec_set(camera.pan,vector(ent.pan,-10,0)); // look in player direction, slighty down      
		wait(1);
	}
}

function ninja_move()
{
	camera_follow(me);
	
	VECTOR vFeet;
	vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex
	my.STATE = 0;
	var walk_speed;
	
	//walking with the sword in hand state
	while(1)
	{
		VECTOR move_to_vector;
		var distance_to_ground;
		
		if(my.STATE == 0)
		{
			my.ANIMATION += 5 *time_step;
			ent_animate(me,"idleSWA",my.ANIMATION,ANM_CYCLE);
			
			if(key_cuu == 1)
			{
				ent_blend("runWS",0,15);
				my.ANIMATION = 1;
				my.STATE = 1;
			}
			/*
			if(key_space == 1)
			{
				my.ANIMATION = 1;
				my.STATE = 3;
			}
			*/
			if(key_t == 1)
			{
				my.ANIMATION = 0;
				my.STATE = 5;
			}
		}
		if(my.STATE ==1)
		{
			//rotate player with the left and right keys
			my.pan += (key_cul-key_cur)*5* time_step;
			//move the entity forward
			var distance = (key_cuu) * 5 *time_step;
			c_move(me,vector(distance,0,0),NULL,GLIDE);
			var rotateAround = (key_cud)* 5 * time_step;
			c_rotate(me,vector(rotateAround,0,0),GLIDE);
			
			//animate the player
			my.ANIMATION += 2* distance;
			ent_animate(me,"runWS",my.ANIMATION,ANM_CYCLE);
			
			// adjust entity to the ground height, using a downwards trace
			c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
			my.z = hit.z - vFeet.z; // always place player's feet on the ground
			
			if(!key_cuu)
			{
				my.ANIMATION = 1;
				my.STATE = 0;
			}
		}
		/*
		if(my.STATE == 3)
		{
			var gravity = 6;
			my.z += 4 * gravity;
			ent_animate(me,"jump",my.ANIMATION,0);
		   my.ANIMATION = 1;
				
		}
		*/
		if(my.STATE == 4)
		{
			my.ANIMATION += 5 *time_step;
			ent_animate(me,"idleSWI",my.ANIMATION,ANM_CYCLE);
		}
		if(my.STATE == 5)
		{
			ent_animate(me,"takeSWO",my.ANIMATION,0);
			my.STATE = 4;
		}
		if((my.STATE == 4) && key_cuu == 1)
		{
				//rotate player with the left and right keys
			my.pan += (key_cul-key_cur)*5* time_step;
			//move the entity forward
			var distance = (key_cuu) * 5 *time_step;
			c_move(me,vector(distance,0,0),NULL,GLIDE);
			var rotateAround = (key_cud)* 5 * time_step;
			c_rotate(me,vector(rotateAround,0,0),GLIDE);
			
			//animate the player
			my.ANIMATION += 2* distance;
			ent_animate(me,"run",my.ANIMATION,ANM_CYCLE);
			
			// adjust entity to the ground height, using a downwards trace
			c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
			my.z = hit.z - vFeet.z; // always place player's feet on the ground
			
			if(!key_cuu)
			{
				my.ANIMATION = 1;
				my.STATE = 0;
			}
		}
		
		
		wait(1);
	}
}



Last edited by Tman; 02/09/10 16:25.
Re: Script issue [Re: Tman] #309497
02/09/10 19:25
02/09/10 19:25
Joined: Sep 2009
Posts: 1,032
Budapest
Aku_Aku Offline
Serious User
Aku_Aku  Offline
Serious User

Joined: Sep 2009
Posts: 1,032
Budapest
Maybe this stuff will help you, to know better the movement with this engine:
KHMovement discussion
You can download the original document at the Free Resources search for KHMovement or KH_Movement.
Also you can found more topics here that cover this problem.

Re: Script issue [Re: Aku_Aku] #309510
02/09/10 20:08
02/09/10 20:08
Joined: Oct 2009
Posts: 60
T
Tman Offline OP
Junior Member
Tman  Offline OP
Junior Member
T

Joined: Oct 2009
Posts: 60
Thanks for the reply, I have read those and I also have read the lite-c workshop and that is where I got the idea for the state's which is nice. The problem is that I am trying to make him jump and it doesn't play the jump animation and then when I tell it to go to a state to pull his weapon and it put it away it seems to pass the animations and go to the next state of playing it's idle animation. Also how would I implement gravity into my code so that it would have the player fall to the ground after I press jump?

Re: Script issue [Re: Aku_Aku] #309512
02/09/10 20:20
02/09/10 20:20
Joined: Jan 2004
Posts: 439
G
Gamesaint762 Offline
Senior Member
Gamesaint762  Offline
Senior Member
G

Joined: Jan 2004
Posts: 439
It seems as if hes asking for help playing an animation and not trying to make player walk or run. I dont think KH movement will help in this case as this is set up for player to be in states and KH is not.

Re: Script issue [Re: Gamesaint762] #309516
02/09/10 20:33
02/09/10 20:33
Joined: Sep 2009
Posts: 1,032
Budapest
Aku_Aku Offline
Serious User
Aku_Aku  Offline
Serious User

Joined: Sep 2009
Posts: 1,032
Budapest
I read the KH_Movement document and it contains a chapter of gravity and jump. But i can imagine the starter of the thread wants another approach of moving.

Last edited by Aku_Aku; 02/09/10 20:35.
Re: Script issue [Re: Aku_Aku] #309542
02/09/10 22:29
02/09/10 22:29
Joined: Oct 2009
Posts: 60
T
Tman Offline OP
Junior Member
Tman  Offline OP
Junior Member
T

Joined: Oct 2009
Posts: 60
That is correct, for some reason the code I have skips some animations and plays others. Plus I need to find a way to implement the jump.

Re: Script issue [Re: Tman] #309588
02/10/10 03:45
02/10/10 03:45
Joined: Oct 2009
Posts: 60
T
Tman Offline OP
Junior Member
Tman  Offline OP
Junior Member
T

Joined: Oct 2009
Posts: 60
I also have an issue with blend animations, if someone could look at my script and tell me what I am doing wrong I would appreciate it. I am just looking to add jump, blend the animations from run to idle and then have it stop skipping over animations any help appreciated.

Re: Script issue [Re: Tman] #309589
02/10/10 04:38
02/10/10 04:38
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
To analyze the problems within the code you should remove only work on one thing at once.
Within the posted part there are three things:
- animating
- movement(jumping)
- state switching

Remove everything, but one of those, and get that working, before you add anything else. Or, make three test entities and test functions where you test each separately from each other. When you get the test functions working, combine them to the final code.

Re: Script issue [Re: Pappenheimer] #309631
02/10/10 13:18
02/10/10 13:18
Joined: Oct 2009
Posts: 60
T
Tman Offline OP
Junior Member
Tman  Offline OP
Junior Member
T

Joined: Oct 2009
Posts: 60
Thanks for the advice, now that is how I started I created two states idle without weapon and run without weapon and then I did key presses to make sure they work and that worked fine except the blend function. Now I added more functions when I got the first two to work and what I am looking for is to get the next phase to work by blending and then getting the jump and then the animations not to skip. Any advice on how to implement the blend first?

Re: Script issue [Re: Tman] #309648
02/10/10 15:25
02/10/10 15:25
Joined: Oct 2009
Posts: 60
T
Tman Offline OP
Junior Member
Tman  Offline OP
Junior Member
T

Joined: Oct 2009
Posts: 60
Ok now I have broken down my script and tyring to get just the blend function to work when he starts and stops moving, can anyone help me with this?
Code:
//walking withOut the sword in hand state
	while(1)
	{
		
		//default state
		if(my.STATE == 0)
		{
				//rotate player with the left and right keys
			my.pan += (key_cul-key_cur)*5* time_step;
			my.ANIMATION += 2 *time_step;
		  ent_animate(me,"idleSWA",my.ANIMATION,ANM_CYCLE);
			
		}
		//the run state without the sword in hand
		if(my.STATE ==1)
		{
			//rotate player with the left and right keys
			my.pan += (key_cul-key_cur)*5* time_step;

			//move the entity forward
			var distance = 25 *time_step;
			c_move(me,vector(distance,0,0),NULL,GLIDE);
			
			ent_blend("runWS",25,45);
			//animate the player
			my.ANIMATION += 15 * time_step;
			ent_animate(me,"runWS",my.ANIMATION,ANM_CYCLE);
			
			// adjust entity to the ground height, using a downwards trace
			c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
			my.z = hit.z - vFeet.z; // always place player's feet on the ground
				
		}
		if((key_cuu == 1)&& my.STATE == 0)
		{
			my.ANIMATION = 0;
			my.STATE = 1;
		}
		else if((!key_cuu)&& my.STATE == 1)
		{

			if(my.ANIMATION > 100)
			{
				ent_blend("idleSWA",5.5,50);
				
			}
			my.STATE = 0;
		}



It just seem not to blend correctly.

Last edited by Tman; 02/10/10 16:29.
Page 1 of 2 1 2

Gamestudio download | 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