Scripts / Periodically Show and Hide an entity (with a single script)

Author
Message
Sparrowhawk
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 12th Apr 2011
Location: Planet Magrathea
Posted: 16th Jan 2016 00:31
I'm trying to periodically show and hide two entities.

That is I have entity '25' and '26' and I when 25 is visible 26 is to be hidden and the other way around.

My understanding was I'd need a way of measuring time, and then two 'states':



Unfortunately it doesn't seem this works, once entity 25 is hidden it appears it cannot be shown again (same for 26)
Any ideas? I did a search and came up with a thread on 'Show/Hide' but that only seemed to relate to events from trigger zones.
The script needs to run the whole time - I assign it to an object which I set to Always Active.
Custom Mac Pro (2014): OSX 10.11 (El Capitan) and Windows 10 Pro:
Xeon E5 v2 @ 3.7Ghz [9775]; Dual AMD FirePro D500 (6GB GDDR5) [3769]; 12GB RAM [2517]; 512GB SSD [9074];
perelect
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 16th Jan 2016 06:22
Hi Sparrowhawk,

This script should do what you want, as soon as it loads it starts running and keep running all the time.

Cheers

Desktop: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz (8 CPUs), ~3.6GHz, Windows 8.1 64-bit, 16 GB Ram, NVIDIA GeForce GTX 750 Ti, Display Memory: 4018 MB. Resolution 1360x768, Passmark 3528.
Laptop: Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2336 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)
Sparrowhawk
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 12th Apr 2011
Location: Planet Magrathea
Posted: 16th Jan 2016 12:13
Thanks!
Is there anything specific I was doing wrong with mine?
Custom Mac Pro (2014): OSX 10.11 (El Capitan) and Windows 10 Pro:
Xeon E5 v2 @ 3.7Ghz [9775]; Dual AMD FirePro D500 (6GB GDDR5) [3769]; 12GB RAM [2517]; 512GB SSD [9074];
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 16th Jan 2016 13:23
from the looks of it you just forgot to reset the timer so it could check for the next delay
so in your case that would be resetting timeRead back to 0 (or g_Time)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
perelect
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 17th Jan 2016 04:05 Edited at: 17th Jan 2016 11:54
Hi Sparrowhawk
smallg is correct the "current time" was never being reset/updated each cycle, so it was basically a "starting time"
I edited your code with comment to show you what was happening, it also works now.

I already had the other script, for some flashing lights, I just changed it to suit your needs..

Note: When you hide an entity its physical mesh is still on the map, so if the entity its large enough it will obstruct the player and other ai entites. That is, it will act like a barrier that you cannot get passed. So if you don't want this you need to turn its collision off when you hide it, and back on when you show it again, like I did in the first script.
Cheers.





Here is another way it could be done..


Desktop: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz (8 CPUs), ~3.6GHz, Windows 8.1 64-bit, 16 GB Ram, NVIDIA GeForce GTX 750 Ti, Display Memory: 4018 MB. Resolution 1360x768, Passmark 3528.
Laptop: Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2336 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)

Login to post a reply

Server time is: 2024-12-22 12:43:06
Your offset time is: 2024-12-22 12:43:06