UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

[TUTORIAL] Rotate Multiple Entities - By: Vertasea

broken avatar :(
Created 4 years ago
by Vertasea
0 Members and 1 Guest are viewing this topic.
581 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 6 September 2019
Last active: 2 years ago
Posts
10
Respect
Forum Rank
Legless Crawler
Primary Group
Community Mapper
My Groups
More
×
Vertasea's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Vertasea's Contact & Social Links
 
======================================================================================
A SCRIPT
BY: VERTASEA
    ======================================================================================
ROTATE MULTIPLE ENTITIES
This script can handle multiple rotating ents.
======================================================
Features that can be set via kvp:
Choose rotation direction.
Set rotation speed.
Require power to rotate/ or rotate without power.
Play a looping sound on the rotating ent.


USES:
This script would be good to add to a map with ceiling fans, vent fans, or if you want props to rotate like the gif above.
If you want anything to rotate in your map this is a easy way to do it.

Instructions:

In Radiant add a script_model or a script_brushmodel.
Besure to look at the script doc within the script to see what all kvp to add to your script_model or script_brushmodel.


Thread this function inside of mapname.gsc in main() UNDER maps\_zombiemode::main();

Code Snippet
cs
// Rotate entitys
level thread get_rotate_ents();
Copy this and paste it at the bottom of mapname.gsc
Code Snippet
cs
/*============================== SCRIPT DOC BEGIN ==============================//

REQUIRED: "targetname" = "rotate_ent" // Must be a script_model or a script_brushmodel
REQUIRED: "script_noteworthy" = "DIR" // DIR = Direction  - Choose "pitch", "roll", or "yaw"

OPTIONAL: "script_transition_time" = "NUMBER" // NUMBER = Any number you want in seconds. Lower the number = faster rotation. Lowest number is 0.05
OPTIONAL: "script_string" = "needs_power" // Don't add this kvp if you want it to rotate when the game starts
OPTIONAL: "script_sound" = "sound_alias_name" // If you want a sound to play from the ent make sure it's 3D and LOOPING

//=============================== SCRIPT DOC END ===============================*/

get_rotate_ents() {

    e_models = GetEntArray("rotate_ent", "targetname");

    for(i = 0; i < e_models.size; i++) {

        e_models[i] thread handle_rotating_ents();
    }
}

handle_rotating_ents() {

    if(!isdefined(self.script_noteworthy)) {
        return;
    }
    if(isdefined(self.script_transition_time)) {
        time = self.script_transition_time;
    }else{
        time = 1;
    }
    if(isdefined(self.script_string) && self.script_string == "needs_power") {
        flag_wait("electricity_on"); // wait for power
    }
    if(isdefined(self.script_sound)) {
        self PlayLoopSound( self.script_sound );
    }
   
    while (true) {

        switch(self.script_noteworthy) {

            case "pitch":
                self RotatePitch(360, time);
                break;
            case "yaw":
                self RotateYaw(360, time);
                break;
            case "roll":
                self RotateRoll(360, time);
                break;
        }
        wait(time - .1);
    }
}

If you use this a credit would be appreciated thanks.
If you find any bugs or have any issues please let me know.
:clap:1

 
Loading ...