How do I synchronize moving objects?
Moderator: Moderators
Try this:
I only added a local.pole show and a local.pole hide line... no idea if it makes a difference 
Code: Select all
pole_prep:
local.POLE_SEPERATION = 3680 // distance between poles
local.SPEED = 1536.0 // terrain speed (3 X 512)
local.poles = $pole1::$pole2::$pole3::$pole4
local.basepoint = $polewayA.origin
local.movevec = $polewayB2.origin - local.basepoint
local.trackdist = vector_length local.movevec
local.dirvec = (1.0 / local.trackdist) * local.movevec // unit vector
local.poles[1].origin = $polewayA.origin
local.dist = 0.0 // distance travelled
//pole movement loop
while(1)
{
// space the poles along the track
for(local.i = 1; local.i <= local.poles.size; local.i++)
{
local.pole = local.poles[local.i]
local.pole show
local.dist_on_track = local.dist + local.POLE_SEPERATION * (local.i - 1)
if(local.dist_on_track > local.trackdist)
{
// move back to the beginning
local.dist_on_track -= local.trackdist
local.pole hide
}
local.pole.origin = local.basepoint + local.dist_on_track * local.dirvec
}
waitframe
local.dist += local.SPEED * 0.05
// this is only to prevent the dist variable from getting too large
if(local.dist > local.trackdist)
local.dist -= local.trackdist
}
end
nope
Does not work. The poles that have returned stay hidden untill all four poles have returned. Then they all show at the same time and it starts all over again. Also the "hide" does not happen fast enough, so the returning poles still flicker on there way back to the start point.
Please excuse my stupidity but whats wrong with:
Code: Select all
local.poles[1] hide
local.poles[1] time .005
local.poles[1] moveto $polewayA
local.poles[1] waitmove
local.poles[1] showShuriken1
moveto
Nothing, but that is originally how I had it and the poles got out of sync with each other.
I tryed this, but it seems to ignore the moveto lines.
I tryed this, but it seems to ignore the moveto lines.
Code: Select all
if(local.dist_on_track > local.trackdist)
{
// move back to the beginning
local.pole time .001
local.pole moveto $polewayC
waitmove
local.pole moveto $polewayD
waitmove
local.dist_on_track -= local.trackdist
}
Last edited by tltrude on Fri Sep 03, 2004 2:03 am, edited 1 time in total.
array
I think the problem is that it uses a "Constant array" rather than a "Targetname array" for the poles. Would it be better to just name all the poles "pole" and then index them with a for loop?
Re: array
I can't see why that would mattertltrude wrote:I think the problem is that it uses a "Constant array" rather than a "Targetname array" for the poles. Would it be better to just name all the poles "pole" and then index them with a for loop?
SO?
So, how do I fix it?
I don't really understand how your thread moves the poles.
Is it changing the poles origin by one unit 14720 times?
What does (-=) and (+=) mean?
Can I replace "local.basepoint" with "$polewayA.origin"?
I'm guessing that to get the pole to go back, the vector direction is reversed from ( 0 -14720 0) to ( 0 14720 0).
Am I right?
I don't really understand how your thread moves the poles.
Is it changing the poles origin by one unit 14720 times?
What does (-=) and (+=) mean?
Can I replace "local.basepoint" with "$polewayA.origin"?
I'm guessing that to get the pole to go back, the vector direction is reversed from ( 0 -14720 0) to ( 0 14720 0).
Am I right?
Re: SO?
local.a -= local.b means local.a = local.a - local.b, and similar for +=. Hence the origin of the poles does not increase with 1 unit but with 0.05 * local.SPEED each frametltrude wrote:So, how do I fix it?
I don't really understand how your thread moves the poles.
Is it changing the poles origin by one unit 14720 times?
What does (-=) and (+=) mean?
Yes... I personally hate to use targetnames all throughout a script because they may be subject to change... hence I usually store them in some universal variable somewhere at the top of the script... it's only personal preference though so you can change it as you like.Can I replace "local.basepoint" with "$polewayA.origin"?
No not at allI'm guessing that to get the pole to go back, the vector direction is reversed from ( 0 -14720 0) to ( 0 14720 0).
Am I right?
Quote:
Code: Select all
if(local.dist_on_track > local.trackdist)
{
// move back to the beginning
local.dist_on_track -= local.trackdist
}
local.pole.origin = local.basepoint + local.dist_on_track * local.dirvec
Hope this clears it up somehow
ok
Thanks, that helped a lot! But, I still don't understand why I can't get the retuning pole to loop underground. Below is the script with all the know value variables removed. It worked the same as before until I added an offset. Now, all four poles stay underground until they get to polewayB. Then they all pop up together and start sending the poles back one by one to be assembled underground again.
So basically, I don't know why the four poles act as one. Nor do I understand why they pop up 3680 units before they reach polewayB2 (the endpoint) and not one by one at polewayA.
There are two waypoints underground ($polewayC and $polewayD) which are not being used, and $polewayB is only being used as a reference to spawn $polewayB2. I can add a fifth pole, if needed.
I am sorry to be such a pest about this, but your thread is unuseable if the poles return above ground.
So basically, I don't know why the four poles act as one. Nor do I understand why they pop up 3680 units before they reach polewayB2 (the endpoint) and not one by one at polewayA.
Code: Select all
// Test poles
// ARCHITECTURE: ATOMIC
// SCRIPTING: ATOMIC & TLTRUDE
main:
// set scoreboard messages
setcvar "g_obj_alliedtext1" "test poles!"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""
setcvar "g_scoreboardpic" ""
level waittill prespawn
//***Precache Dm Stuff
exec global/DMprecache.scr
level.script = maps/dm/test_jpoles.scr
exec global/ambient.scr m6l3a // for background sound
spawn info_waypoint targetname "polewayB2"
$polewayB2.origin = ($polewayB.origin + ( -3680 0 0 ))
thread pole_prep
level waittill spawn
end
//------------------------------>
// Pole Thread
//------------------------------>
pole_prep:
local.poles = $pole1::$pole2::$pole3::$pole4
local.poles[1].origin = $polewayA.origin
local.dist = 0.0
//pole movement loop
while(1)
{
for(local.i = 1; local.i <= local.poles.size; local.i++)
{
local.poles[local.i].offset = ( 0 0 0 )
local.pole = local.poles[local.i]
local.dist_on_track = local.dist + 3680 * (local.i - 1)
if( local.dist_on_track > 14720 )
{
local.dist_on_track = ( local.dist_on_track - 14720 )
local.poles[local.i].offset = ( 0 0 -1000 )
}
local.pole.origin = $polewayA.origin + ((local.dist_on_track * ( -1 0 0 )) + local.poles[local.i].offset )
}
waitframe
local.dist = ( local.dist + 76.8 )
if( local.dist > 14720 )
local.dist = ( local.dist - 14720 )
}
end
I am sorry to be such a pest about this, but your thread is unuseable if the poles return above ground.
Hmm
well here's some things you could still try:
- Use plain Entities instead of ScriptSlaves.
- Instead of local.pole.origin = (x y z) use local.pole origin (x y z)
- Try the below commands:
local.pole stationary
local.pole effects "+antisbjuice"
Here's a convenient method for turning a script_object into an Entity:
- Use plain Entities instead of ScriptSlaves.
- Instead of local.pole.origin = (x y z) use local.pole origin (x y z)
- Try the below commands:
local.pole stationary
local.pole effects "+antisbjuice"
Here's a convenient method for turning a script_object into an Entity:
Code: Select all
local.script_object_poles = $pole1::$pole2::$pole3::$pole4
for(local.i = 1; local.i <= local.script_object_poles.size; local.i++)
{
local.poles[local.i] = waitthread reclassobject local.script_object_poles[local.i] Entity
}
// (...)
// -------------------
// spawns a new object with same brushmodel and removes old object
reclassobject local.object local.newclass:
local.newobj = spawn local.newclass origin local.object.origin angles local.object.angles model local.object.brushmodel
local.object remove
end local.newobj
strange
A strange thing happened. I increased the distance between wayponts to 18400 units and added a fifth pole. Now I can not see the returning poles! It still needs to be tested on the full map.
It might be that the map just has a little more or less fps and that what fixed it. I have been testing terrain brushes on the test map too, and they may have caused the change.
I tried the "entity" thing and it works, but it does not seem to do anything different for the 5 poles version. I did not try it with 4 poles. I don't know how, or where, to use those other two new lines.
It might be that the map just has a little more or less fps and that what fixed it. I have been testing terrain brushes on the test map too, and they may have caused the change.
I tried the "entity" thing and it works, but it does not seem to do anything different for the 5 poles version. I did not try it with 4 poles. I don't know how, or where, to use those other two new lines.
Code: Select all
main:
// set scoreboard messages
setcvar "g_obj_alliedtext1" "test poles!"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""
setcvar "g_scoreboardpic" ""
level waittill prespawn
//***Precache Dm Stuff
exec global/DMprecache.scr
level.script = maps/dm/test_jpoles.scr
exec global/ambient.scr m6l3a // for background sound
spawn info_waypoint targetname "polewayB2"
$polewayB2.origin = ($polewayB.origin + ( -3760 0 0 ))
spawn info_waypoint targetname "polewayA2"
$polewayA2.origin = ($polewayA.origin + ( 3600 0 0 ))
thread pole_prep
level waittill spawn
end
//------------------------------>
// Pole Thread
//------------------------------>
pole_prep:
local.poles = $pole1::$pole2::$pole3::$pole4::$pole5
local.poles[1].origin = $polewayA2.origin
local.dist = 0.0
//poles movement loop
while(1)
{
for(local.i = 1; local.i <= local.poles.size; local.i++)
{
local.pole = local.poles[local.i]
local.dist_on_track = local.dist + 3680 * (local.i - 1)
if( local.dist_on_track > 18400 )
{
local.dist_on_track = ( local.dist_on_track - 18400 )
}
local.pole.origin = $polewayA2.origin + (local.dist_on_track * ( -1 0 0 ))
}
waitframe
local.dist = ( local.dist + 76.8 )
if( local.dist > 18400 )
local.dist = ( local.dist - 18400 )
}
end
test
I tested it in the full size map and all is well. so, a big thanks to you jv_map!!!!!!!!!!!

