Mobile --> Immobile --> Mobile

Mobile --> Immobile --> Mobile

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
Alchemist
Posts: 81
Joined: 21 Oct 2005, 23:46

Mobile --> Immobile --> Mobile

Post by Alchemist »

I have a mobile unit, which is initially set to OFF.
I can move this unit wherever I want while it is OFF.
Ideally, when it is turned ON it does an animation and should stop.
Then, when it is turned OFF, again, it is free to move.

The problem is, when I hit ON, it continues to move freely as if it were turned OFF.

My code:

Code: Select all

Activate()
{
	some cool animation here;
	set MAX_SPEED to [0];
	start-script RequestState(0);
}
Any ideas?
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

Re: Mobile --> Immobile --> Mobile

Post by Peet »

Setting MAX_SPEED to 0 doesn't work. Set it to 1 (not [1]!), which is tiny enough to be 0 for all practical purposes.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Mobile --> Immobile --> Mobile

Post by Argh »

Yes. Set to 1. I really don't think it's moving at all at that point, at least I've never seen it move.

You cannot do this with turning, however, and you will find your newly-immobilized unit still turns, as if it is moving.

Instead, you must run a loop where to you keep turning the unit every frame to the desired heading, while a condition lasts. Which is rather expensive to run, CPU-wise, so you definitely don't want to plaster this kind of code willy-nilly on things that don't actually need it.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Mobile --> Immobile --> Mobile

Post by lurker »

"must", Argh? The unit now uses a call to Spring.MoveCtrl.Enable() to shut off all movement, turning, and pathing.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Mobile --> Immobile --> Mobile

Post by Argh »

Meh, truthfully, I haven't played with that.

When reset, does the Unit return to its previous behavior? If so, it'd probably be far cheaper to run that and then supply no MoveControl stuff. Lemme go look at that, I did all of this before messing with BOS-->Lua...
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Mobile --> Immobile --> Mobile

Post by Argh »

Okie doke, just tested it... it's easy, and it works. Only problem that I see is that you lose the previous move commands, so you cannot do it for a unit in the middle of a Patrol and expect it to resume, etc., without storing it somewhere. Better by far than running COB all the time, though.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Mobile --> Immobile --> Mobile

Post by aegis »

You could call a function in lua to store the current move queue then apply the movectrl. On removing the movectrl, simply reapply the queue (and update it with any new orders if desired).
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Mobile --> Immobile --> Mobile

Post by KDR_11k »

I use morphing but whatever floats your boat...
User avatar
Alchemist
Posts: 81
Joined: 21 Oct 2005, 23:46

Re: Mobile --> Immobile --> Mobile

Post by Alchemist »

How would you do the store and reapply of queue?
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: Mobile --> Immobile --> Mobile

Post by Pxtl »

Alchemist wrote:How would you do the store and reapply of queue?
See Kernel Panic - the Virus/Exploit units are such an example of a unit that morphs into an immobile... I'm pretty sure it has queue persistance.
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Mobile --> Immobile --> Mobile

Post by yuritch »

Some things about immobilizing via MoveCtrl that I'm not sure about:
Wouldn't Spring.MoveCtrl.Enable() also prevent things like unit being thrown off by high-impulse explosions? And what happens if a crater is made under such unit, won't it stay 'afloat' midair?
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Mobile --> Immobile --> Mobile

Post by lurker »

Being immune to impulse is good with this unit pretending to be a building, and ground deformation is an issue, but you have to consider the survivability of such a blast.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Mobile --> Immobile --> Mobile

Post by trepan »

Are you sure that ground deformation
would be an issue when using MoveCtrl? ;-)
Post Reply

Return to “Game Development”