scripting:snippets
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
scripting:snippets [2022/08/11 13:43] – jerryhopper | scripting:snippets [2022/08/11 13:58] (current) – jerryhopper | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Snippets ====== | ====== Snippets ====== | ||
- | |||
- | |||
- | ===== Basics : Get a Entity ===== | ||
- | |||
- | |||
- | One of the most used commands is probably ' | ||
- | |||
- | Notice the variable name ' | ||
- | |||
- | ==== Example 1 ==== | ||
- | |||
- | Get the entity of a vehicle with the name ' | ||
- | |||
- | GenericEntity btr = GenericEntity.Cast(GetWorld().FindEntityByName(" | ||
- | |||
- | |||
- | **Lets break down this line.** | ||
- | |||
- | This is where we declare our variablename and type, where the name is ' | ||
- | |||
- | 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 2 ==== | ||
- | |||
- | 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 soldier_c = CharacterControllerComponent.Cast(soldier.FindComponent(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 | ||
< | < | ||
Line 97: | Line 28: | ||
soldier_c.SetFireWeaponWanted(1) | soldier_c.SetFireWeaponWanted(1) | ||
</ | </ | ||
+ |
scripting/snippets.1660221800.txt.gz · Last modified: 2022/08/11 13:43 by jerryhopper