Gamestudio Links
Zorro Links
Newest Posts
Why Zorro supports up to 72 cores?
by 11honza11. 04/26/24 08:55
M1 Oversampling
by 11honza11. 04/26/24 08:32
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (VoroneTZ, Quad, EternallyCurious, 1 invisible), 828 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
changing skin during movement. #460251
06/21/16 17:33
06/21/16 17:33
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline OP

Expert
Realspawn  Offline OP

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
I want to change the models skin 3 times in a loop during movement
what would be the best way ? using ent_morphskin ?

anyone can provide an example ?

thx laugh


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: changing skin during movement. [Re: Realspawn] #460253
06/21/16 18:25
06/21/16 18:25

M
Malice
Unregistered
Malice
Unregistered
M



if the model has all skins packed into the mdl file than.

Code:
var time_change=0;

while(1)
{
time_change+=time_step/16;
if(time_change>1)
{
 time_change+=1;
 my.skin+=1;
}
if(time_change>=3)
time_change=0;
wait(1);
}



changes skins every second for 3 skins

basically my.skin+=nX
http://www.conitec.net/beta/aentity-skin.htm
manual example
Code:
action flipskins()
{
  while (1)
  {
    my.skin = my.skill1 % 32; // 32 Skins
    my.skill1 += time_step; // 16 skins per second
    wait (1);
  }
}



Going to check this for errors after posting
Code:
var dist_to_move=0;
var skin_count=0;
// vSpeed = movement speed;
while(1)
{
 // ...STUFF
 dist_to_move=(vSpeed*3)*time_step;
 skin_count=vSpeed/dist_to_move;
 c_move(my,vector(vSpeed*time_step,nX,nX),nullvector,STUFF);
 my.skin=integer(skin_count);
wait(1);
}


Last edited by Malice; 06/21/16 18:34.
Re: changing skin during movement. [Re: ] #460254
06/21/16 18:31
06/21/16 18:31
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline OP

Expert
Realspawn  Offline OP

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
will have a go on this laugh


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: changing skin during movement. [Re: Realspawn] #460255
06/21/16 18:42
06/21/16 18:42

M
Malice
Unregistered
Malice
Unregistered
M



Working

flip_rate = highvaule == slow change or lowvalue == fast change

OLD CODE WITH BUG
Click to reveal..
Code:
action my_action()
{
	set(my,SHADOW|CAST);
	var dist_to_move=0;
	var skin_count=0;
	var vSpeed=2;
	int flip_rate=18;
	while(1)
	{
		
		dist_to_move=(vSpeed*flip_rate)*time_step;
		skin_count+=(vSpeed*time_step)/dist_to_move;
		skin_count%=3;
		c_move(my,vector(vSpeed*time_step,0,0),nullvector,GLIDE);
		my.skin=integer(skin_count);
		wait(1);
	}
}



Need to check this line skin_count%=3;
??is returning 1-3 or 0-2?????
EDIT - Yes error in code ... New code below
EDIT2 - Code notes - vSpeed should == 0 if no key input so like
vSpeed = nX*(key_w-key_s);
Code:
action my_action()
{
	set(my,SHADOW|CAST);
	var dist_to_move=0;
	var skin_count=0;
	var vSpeed=2;
	int flip_rate=18;
	while(1)
	{
		
		dist_to_move=(vSpeed*flip_rate)*time_step;
		skin_count+=(vSpeed*time_step)/dist_to_move;
		skin_count%=4;
		c_move(my,vector(vSpeed*time_step,0,0),nullvector,GLIDE);
		my.skin=clamp(integer(skin_count),1,3);//integer(skin_count);
		DEBUG_VAR(my.skin,50);
		wait(1);
	}
}



AS Always QnD code could be better..

Last edited by Malice; 06/21/16 18:52.
Re: changing skin during movement. [Re: ] #460256
06/21/16 18:50
06/21/16 18:50
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline OP

Expert
Realspawn  Offline OP

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
why conecting it to speed ? laugh


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: changing skin during movement. [Re: Realspawn] #460257
06/21/16 18:53
06/21/16 18:53

M
Malice
Unregistered
Malice
Unregistered
M



Quote:
I want to change the models skin 3 times in a loop during movement
what would be the best way ?


connected to speed because "during movement"
So skin changes as a fraction of the distance moved at flip_rate number of frames. It's not connected to speed really, it's connected to distance traveled

See final edits above

Last edited by Malice; 06/21/16 18:54.
Re: changing skin during movement. [Re: ] #460258
06/21/16 18:58
06/21/16 18:58

M
Malice
Unregistered
Malice
Unregistered
M



Change code to fix crash == division by 0

changed lines - added key input - added division by 0 check
Code:
vSpeed=2*(key_w-key_s);
		dist_to_move=(vSpeed*flip_rate)*time_step;
		if(dist_to_move)
		skin_count+=(vSpeed*time_step)/dist_to_move;


Re: changing skin during movement. [Re: ] #460259
06/21/16 19:08
06/21/16 19:08

M
Malice
Unregistered
Malice
Unregistered
M



LOL - I'm bored!!

Best and last version but still QnD code
Code changes - removed clamp -- caused 1 to play double
-added back the %=3 modulo -- http://www.conitec.net/beta/avar-Ref.htm
- corrected the skin== 0 by adding +1 to my.skin = int(xN)+1;

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

///////////////////////////////
action my_action()
{
	set(my,SHADOW|CAST);
	var dist_to_move=0;
	var skin_count=0;
	var vSpeed=2;
	int flip_rate=30;
	while(1)
	{
		vSpeed=2*(key_w-key_s);
		dist_to_move=(vSpeed*flip_rate)*time_step;
		if(dist_to_move)
		skin_count+=((vSpeed*time_step)/dist_to_move);
		skin_count%=3;
		c_move(my,vector(vSpeed*time_step,0,0),nullvector,GLIDE);
		my.skin=integer(skin_count)+1;//clamp(integer(skin_count),1,3);
		DEBUG_VAR(my.skin,50);
		wait(1);
	}
}
function main()
{
	vec_set(screen_size,vector(800,400,0));
	vec_set(screen_color,vector(50,1,1)); // dark blue
	vec_set(sky_color,vector(50,1,1)); // dark blue
	video_window(NULL,NULL,0,"My New Game");
	d3d_antialias = 1;
	shadow_stencil = 3;
	fps_max=60;
	level_load("tTest.wmb");
	vec_set(camera.x,vector(-250,0,50));
	vec_set(camera.pan,vector(0,-15,0));

}



Known issues - skin always flips in a cycle 1-3, can not reverse 3-1.
probable cause - skin_count%=3;

Last edited by Malice; 06/21/16 19:13.
Re: changing skin during movement. [Re: ] #460264
06/22/16 08:37
06/22/16 08:37
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline OP

Expert
Realspawn  Offline OP

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
still amazed how much lines are needed for stuff
that look so simple laugh


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: changing skin during movement. [Re: Realspawn] #460267
06/22/16 15:18
06/22/16 15:18
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline OP

Expert
Realspawn  Offline OP

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
got it to work laugh thx malice


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Page 1 of 2 1 2

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