Jump to content
Sign in to follow this  
Koni

Moving a unit from one location to another in a loop

Recommended Posts

I'm trying to move a unit from one location to another, backwards and forwards, in a loop.

Been trying with this for a few hours and not much luck . lol

This is the result I'm trying to get.

unitname setPos (getPos loc1);

sleep 5;

unitname setPos (getPos loc2);

sleep 5;

unitname setPos (getPos loc1);

sleep 5;

unitname setPos (getPos loc2);

etc etc, but in a better format, without needing endless gibberish

Thanks

Share this post


Link to post
Share on other sites

This is one solution.

[] spawn {
while {true} do {
	_cycle = [loc1, loc2];
	_obj = unitname;
	{
		 sleep 5.0;
		 _obj setPos (getPos _x);
	} forEach _cycle;
};
};

Share this post


Link to post
Share on other sites

That was a world away from what I was trying.

Took the hen script you did earlier, and chopped and changed it every which way, got it to move the unit to the first loc1 but nothing after that.

Brilliant, thanks, yet again Muzzleflash :)

Share this post


Link to post
Share on other sites

Completely forgot about that animal thread. Glad you got it working :)

I'm a bit curious why do you need to teleport something between some spots every couple of seconds?

Share this post


Link to post
Share on other sites

It's because of the animal script.

Part of the first mission of what is becomming a campaign I'm working on now, is to find and steal Hens and Goats for your Farmstead.

Since just teleporting animals to another location dosen't work propperly "they walk all the way back to where they started from" if you teleport them, they now get deleted and replacements get spawned back at the Farmstead.

To spawn them and be able to count them, my only solution I could figure out was to join them to a group, where the group leader is actually a hidden man, then I could count how many animals was in that group.

Now when I stole goats, and they spawned at the farm, they would join their hidden man unit so I could count them, but they would all just line up in formation and stand still in a big V shape, which looked stupid.

So my logic was to have the HIDDEN unit leader man move around on waypoints around the farm every so often, making the goats follow him, making the scene look realistic, having the goats wandering around, BUT if you we're close to the hidden group leader you could hear his footsteps, like a ghost.

So, just teleporting him from one side of the farm to the other, probably every 30 seconds should have the desired effect of the goats wandering around following their leader, but not hearing the leaders footsteaps.

Sorry, big explaination, for such a simple task, lol, and most probably there would have been a far easier way of doing what I'm doing.

Share this post


Link to post
Share on other sites

That's an uhmm very interesting solution.

If you can group the animals might have been simpler to just give them a waypoint every now and then.

http://community.bistudio.com/wiki/selectLeader

http://community.bistudio.com/wiki/move

Nevermind misread. But gues you could just use doMove on every animal to some random pos in the farm every now and then.

Edited by Muzzleflash

Share this post


Link to post
Share on other sites

Animals don't respond to commands though, well mine never have anyway :)

I've tried in the past, and they just stand there.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×