View Full Version : Xmodel Moving
Loveboy
26th December 2012, 21:46
Hello Guys, i need help!
I want to move a xmodel, but the problem is i can't create an entry (script brushmodel) with a xmodel.
Do you maybe know how can i make move the xmodel?
Jared
26th December 2012, 21:50
Try doing: RightClick to bring up the menu--->script--->model and go from there.
Loveboy
26th December 2012, 21:54
Thank you. If i press n: targetname raygun and i add in script: raygun movez(8,1); it will move with RightClick to bring up the menu--->script--->model?
kung foo man
27th December 2012, 00:40
If you want to move a script_brushmodel and a xmodel, you need to link the xmodel to the brushmodel per script, because they are two separate entities.
Loveboy
27th December 2012, 08:37
ok, you know maybe the script?
kung foo man
27th December 2012, 15:12
It should be only:
theModel = getEnt("theModel", "targetname");
theBrush = getEnt("theBrush", "targetname");
theModel linkTo(theBrush);
Loveboy
30th December 2012, 18:24
sry kung
i have this not understand
theModel = getEnt("theModel", "targetname");
theBrush = getEnt("theBrush", "targetname");
theModel linkTo(theBrush);
Ni3ls
31st December 2012, 08:54
You have a scriptmodel with a name and a xmodel with a name. Replace TheModel with xmodel name and theBrush with scriptmodel name. Then this script links the scriptmodel to the xmodel and you can move the scriptmodel with a script.
pollo
31st December 2012, 16:30
Not need to write "enablelinkto();" ?
Ni3ls
1st January 2013, 15:17
Thats COD4 only i thought
serthy
1st January 2013, 21:38
//ingame the only diff. between a misc_model and a misc_brushmodel is their classname
//but you can handle them as the same 'model'
//just gather all the party of your object and move them at the same time in the same way
init()
{
level thread move_brushmodel();
level thread move_brushmodels();
level thread move_xmodel();
level thread move_xmodels();
level thread move_xmodel_and_brushmodel_1();
level thread move_xmodel_and_brushmodel_2();
level thread move_trigger();
level thread link_trigger_and_move();
}
/* gather a brushmodel and move it */
move_brushmodel()
{
brushmodel = getEnt( "brushmodelname" , "targetname" );
if( isDefined( brushmodel ) ) //if there is nothing to move, skip
brushmodel thread moveMe();
}
/* gather an array of misc_brushmodels with the same 'targetname' and move them */
move_brushmodels()
{
brushmodel_array = getEntArray( "brushmodelname" , "targetname" );
if( isDefined( brushmodel_array ) && brushmodel_array.size > 0 ) //if there is nothing to move, skip
{
for( index = 0 ; index < brushmodel_array.size ; index++ )
{
brushmodel = brushmodel_array[index];
if( isDefined( brushmodel ) ) //if there is nothing to move, skip
brushmodel thread moveMe();
}
}
}
/* see there is no difference between a misc_model and a misc_brushmodel */
/* gather a misc_model and move it */
move_xmodel()
{
xmodel = getEnt( "xmodelname" , "targetname" );
if( isDefined( xmodel ) ) //if there is nothing to move, skip
xmodel thread moveMe();
}
/* gather an array of misc_models with the same 'targetname' and move them */
move_brushmodels()
{
xmodel_array = getEntArray( "xmodelname" , "targetname" );
if( isDefined( xmodel_array ) && xmodel_array.size > 0 ) //if there is nothing to move, skip
{
for( index = 0 ; index < xmodel_array.size ; index++ )
{
xmodel = xmodel_array[index];
if( isDefined( xmodel ) ) //if there is nothing to move, skip
xmodel thread moveMe();
}
}
}
/* move your object made out of 1 misc_brushmodel and 1 misc_model */
move_xmodel_and_brushmodel_1()
{
xmodel = getEnt( "xmodelname" , "targetname" );
brushmodel = getEnt( "brushmodelname" , "targetname" );
if( isDefined( xmodel ) ) //if there is nothing to move, skip
xmodel thread moveMe();
if( isDefined( brushmodel ) ) //if there is nothing to move, skip
brushmodel thread moveMe();
}
/* move your object made out of misc_brushmodels and misc_models */
move_xmodel_and_brushmodel_2()
{
entity_array = getEntArray( "entity_name" , "targetname" );
if( isDefined( entity_array ) && entity_array.size > 0 ) //if there is nothing to move, skip
{
for( index = 0 ; index < entity_array.size ; index++ )
{
entity = entity_array[index];
if( isDefined( entity ) ) //if there is nothing to move, skip
entity thread moveMe();
}
}
}
/* since you can only move script_origins, script_models, and script_brushmodels, you have to link your trigger to one of them before it will move!
or you will get an error like the following:
'entity 123 is not a script_brushmodel, script_model, or script_origin: (file 'serthy/_test.gsc', line 217) >> self movez( 1000.0 , 5.0 , 5.0 );'
*/
link_trigger_and_move()
{
trigger = getEnt( "triggername" , "targetname" );
linker = getEnt( "linkername" , "targetname" );
if( !isDefined( trigger ) ) //if there is nothing to move, skip
return;
if( !isDefined( linker ) )//spawn a helper to move the trigger if there is none
linker = spawn( "script_origin" , trigger.origin );
trigger enableLinkTo();
trigger linkTo( linker );
linker thread moveMe();
}
moveMe()
{
if( !isDefined( self ) ) //if there is nothing to move, skip
return;
self moveTo( self.origin + ( 0 , 0 , 1000 ) , 10.0 , 5.0 , 2.0 ); //move 1000 in Z direction
}
this is how I move my triggers, i implemented this in my _utility.gsc, you can do it for rotating etc. as well
moveTriggerTo( point , time , acceleration*_time , deceleration_time )
{
if( !isDefined( self ) )
return;
if( !isDefined( self.linkObject ) )
self.linkObject = spawn( "script_origin" , self.origin );
if( !isDefined( self.enableLinkTo ) )
{
self enableLinkTo();
self.enableLinkTo = true;
}
self linkTo( self.linkObject );
self moveTo( point , time , acceleration*_time , deceleration_time );
}
trigger enableLinkTo(); is only required by triggers, you don't need to call it on other entities
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.