scripting:basics
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
scripting:basics [2022/08/11 13:52] – jerryhopper | scripting:basics [2022/08/11 14:32] (current) – jerryhopper | ||
---|---|---|---|
Line 15: | Line 15: | ||
Notice the variable name ' | Notice the variable name ' | ||
- | ==== Example 1 ==== | + | ==== Example 1 a vehicle |
Get the entity of a vehicle with the name ' | Get the entity of a vehicle with the name ' | ||
Line 24: | Line 24: | ||
**Lets break down this line.** | **Lets break down this line.** | ||
- | This is where we declare our variablename and type, where the name is ' | + | This is where we declare our variablename and type, where the name is ' |
+ | In Enfusion, variables has to be declared of which type they should be. Its fairly self-explanatory if you look at the line below. | ||
GenericEntity btr = | GenericEntity btr = | ||
Line 44: | Line 45: | ||
- | So, the result of the above is that we have a variable with the name ' | + | So, the result of the above is that we have a variable with the name '**btr**' which '**type**' is '**GenericEntity**' |
- | ===== Get a CharacterEntity, | + | ==== Example 2: a Character |
+ | |||
+ | Lets try this with a soldier (character). | ||
+ | |||
+ | 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 ' | ||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | |||
+ | ===== Control | ||
+ | |||
+ | |||
+ | Lets continu from Example #2. We now have an entity, and its time we control it. | ||
+ | |||
+ | ==== Change stance ==== | ||
+ | |||
+ | |||
+ | 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 | ||
+ | |||
+ | |||
+ | Notice that these are ' | ||
+ | |||
+ | Great! | ||
+ | |||
+ | ==== Move ==== | ||
+ | |||
+ | Now lets try make the character move. To move a character, we need to know what speed and direction you want to move. We will use a variable which we declare as a ' | ||
+ | |||
+ | |||
+ | vector direction = {0,0,1}; | ||
+ | |||
+ | The ' | ||
+ | |||
+ | soldier_c.SetMovement(2, | ||
+ | |||
+ | That should do the trick. Your character should be moving in the given direction. |
scripting/basics.1660222331.txt.gz · Last modified: 2022/08/11 13:52 by jerryhopper