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 (TipmyPip, AndrewAMD, NewbieZorro), 16,055 guests, and 7 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
Attach Model #211666
06/17/08 18:11
06/17/08 18:11
Joined: Jan 2002
Posts: 454
Germany
CD_saber Offline OP
Senior Member
CD_saber  Offline OP
Senior Member

Joined: Jan 2002
Posts: 454
Germany
Hello,

I do not understand why the code doesn't work. I have a model (a player with a sword) and separated them as 2 models (because i wanted to assign a fx to the sword). I tried to attach the sword to the playermodel with this code:


action swordaction
{

my.material=glowmodel;

my.passable = ON;
while(1)
{

my.scale_x = player.scale_x;
my.scale_y = player.scale_y;
my.scale_z = player.scale_z;

my.frame = player.frame;

my.x = player.x;
my.y = player.y;
my.z = player.z;
my.pan = player.pan;
my.tilt = player.tilt;
wait(1);
}

my.bright=on; //
my.nofog=on; //

}

But it does not work correctly! The frames do not alway fit, and sometimes it looks like the swords position is wrong... why?

please help me, thank you


Ja, lach du nur du haariges Pelzvieh!
Re: Attach Model [Re: CD_saber] #211693
06/17/08 19:47
06/17/08 19:47
Joined: May 2008
Posts: 73
Richmond, VA (USA)
coma_dose Offline
Junior Member
coma_dose  Offline
Junior Member

Joined: May 2008
Posts: 73
Richmond, VA (USA)
I'm not sure why, I can say that sometimes using a sort of attachment code will mess up due to the fact that there is a gap between when the player's position is updated and when the sword's position is updated. Try putting proc_late(); at the top of the sword code, this will make it so that it is updated AFTER the player instead of before. It may help, it may not, it may help only a little.

Also, are you using ent_animate with anm_cycle to animate the player? Using that and then using my.frame = player.frame tends to mess up around the end of the player animation cycle because the last frame is blended to the first frame. You could either make a code that ent_animates the sword based on the player's animation speed --- ent_animate(me,"walk",player.anim_dist,anm_cycle); --- or you can use anm_add and just make sure that your animations cycle well on their own.

Also, also; instead of this:
Code:
my.scale_x = player.scale_x;
my.scale_y = player.scale_y;
my.scale_z = player.scale_z;


Use this, it's faster, speed is the issue with sync:
Code:
vec_set(my.scale_x,player.scale_x);


Do the same for the other vectors; use vec_set(my.x,player.x); and vec_set(my.pan,player.pan); check out vec_set in the manual.

It's most likely a problem that can be fixed using proc_late(); and vec_set.

Re: Attach Model [Re: coma_dose] #211729
06/18/08 00:15
06/18/08 00:15
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Please ignore the following:
Code:
STRING md_wp1 = "sword1.mdl";

define _eWp1, skill70;
ENTITY* e1;

STRING* sAni1;
var nAniStep = 0;
var nAniMode = 0;
var nAniPer = 0;
var n1 = 0;		// temp var


function wpf_valid1() {
	e1 = NULL;
	if (my._eWp1 == 0) { return(0); }
	e1 = ptr_for_handle(my._eWp1);
	if (e1 == NULL) {
		return(0); 
	}
	return(1);
}
function wpf_align1(_bScale) {
	if (e1 == NULL) { return(0); }
	if (_bScale) { vec_set(e1.scale_x, my.scale_x); }
	vec_set(e1.x, my.x);
	vec_set(e1.pan, my.pan);
	return(1);
}
function wpf_new1(_s, _bAlign, _bScale) {
	if (my._eWp1 != 0) { return(0); }
	if (_s == 0) { return(0); }
	e1 = ent_create(_s, my.x, NULL);
	if (e1 == NULL) { return(0); }
	my._eWp1 = handle(e1);
	e1.passable = ON;
	if (_bAlign) {
		wpf_align1(_bScale);
	}
	return(1);
}
function actorf_ani1(_s, _nStep, &_nPer, _mode) {
	_nPer[0] += _nStep * time_step;
	//_nPer[0] %= 100;
	ent_animate(me, _s, _nStep, _nPer[0], _mode);
	if (wpf_valid1() == 0) { return(1); }

	wpf_align1(0);
	ent_animate(e1, _s, _nStep, _nPer[0], _mode); 
	return(2);
}
function actorf_ani2() {
	n1 = actorf_ani1(sAni1, nAniStep, nAniPer, nAniMode);
	return(n1);
}
action aPlayer {
	wpf_new1(md_wp1, 1, 1);
	while(me != 	NULL) {
		// set nAni sAni, etc.
		actorf_ani2();
		//dump globals back to entity skills
		wait(1);
	}
}


Re: Attach Model [Re: testDummy] #211739
06/18/08 03:24
06/18/08 03:24
Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
draculaFactory Offline
User
draculaFactory  Offline
User

Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
I'm going to try that one too.


Making dreams come true... And being erroneously accused of software piracy by Conitec in the process.

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

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