scripting:snippets
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
scripting:snippets [2022/08/11 13:46] – jerryhopper | scripting:snippets [2022/08/11 13:58] (current) – jerryhopper | ||
---|---|---|---|
Line 2: | Line 2: | ||
+ | < | ||
- | ===== Basics : Get a Entity ===== | ||
- | The examples below need a soldier with the name ' | + | //Get the entity (soldier) |
+ | GenericEntity soldier = GenericEntity.Cast(GetWorld().FindEntityByName(" | ||
- | One of the most used commands is probably ' | + | // |
+ | CharacterControllerComponent soldier_c = CharacterControllerComponent.Cast(soldier.FindComponent(CharacterControllerComponent)); | ||
- | Notice the variable name ' | + | // change |
+ | soldier_c.SetStanceChange(ECharacterStanceChange.STANCECHANGE_TOCROUCH); | ||
- | ==== Example | + | // move soldier |
- | + | vector direction | |
- | Get the entity of a vehicle with the name ' | + | soldier_c.SetMovement(2, |
- | GenericEntity btr = GenericEntity.Cast(GetWorld().FindEntityByName(" | ||
+ | // shoot phase 1 | ||
+ | soldier_c.SetWeaponRaised(true); | ||
+ | soldier_c.SetSafety(false, | ||
- | **Lets break down this line.** | + | // shoot phase 2 |
- | + | soldier_c.SetFireMode(2); | |
- | This is where we declare our variablename and type, where the name is ' | + | soldier_c.SetFireWeaponWanted(1) |
- | + | </ | |
- | GenericEntity btr = | + | |
- | + | ||
- | + | ||
- | So, the variable ' | + | |
- | + | ||
- | When we break it down you'll notice these 2 commands. | + | |
- | + | ||
- | GetWorld().FindEntityByName(" | + | |
- | + | ||
- | GenericEntity.Cast() | + | |
- | + | ||
- | Lets not get too technical, but what you need to know is that we search for the entity ' | + | |
- | + | ||
- | GenericEntity.Cast(GetWorld().FindEntityByName(" | + | |
- | + | ||
- | What does that mean? - it means that the result of your FindEntityByName is ' | + | |
- | + | ||
- | + | ||
- | So, the result of the above is that we have a variable with the name ' | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ==== Example | + | |
- | + | ||
- | Lets try this with a soldier. | + | |
- | + | ||
- | So, we get the entity of a soldier with the name ' | + | |
- | + | ||
- | GenericEntity soldier = GenericEntity.Cast(GetWorld().FindEntityByName(" | + | |
- | + | ||
- | Now we have the ' | + | |
- | This procedure is almost the same as you would get any other entity. | + | |
- | + | ||
- | CharacterControllerComponent | + | |
- | + | ||
- | + | ||
- | So here we have a variable with the name ' | + | |
- | + | ||
- | Now if we want to change the stance of the soldier, we can do so via this CharacterController. | + | |
- | + | ||
- | soldier_c.SetStanceChange(ECharacterStanceChange.STANCECHANGE_TOCROUCH); | + | |
- | + | ||
- | That looks quite straightforward, | + | |
- | + | ||
- | * STANCECHANGE_NONE, | + | |
- | * STANCECHANGE_TOERECTED, | + | |
- | * STANCECHANGE_TOCROUCH, | + | |
- | * STANCECHANGE_TOPRONE | + | |
- | + | ||
- | + | ||
- | Great! | + | |
scripting/snippets.1660221987.txt.gz · Last modified: 2022/08/11 13:46 by jerryhopper