Spring arm ue4 что это

Using Spring Arm Components

The Spring Arm component is used to automatically control how the camera handles situations where it becomes obstructed.

You can use your own character for this tutorial provided it has a Camera component assigned to it. If you do not have a character, it is recommended that you complete the Working with Camera Components tutorial in order to create the basic character being used in this guide first.

In this How-to, we add a Spring Arm component and parent a Camera component to it so that our camera can expand/retract based on gameplay situations. Typically when you add a Camera component to a character for the purposes of creating a third person perspective, you will also want to include a Spring Arm to automatically control how the camera handles situations where the it becomes obstructed by level geometry or other objects in the level.

Spring arm ue4 что это. springArm1. Spring arm ue4 что это фото. Spring arm ue4 что это-springArm1. картинка Spring arm ue4 что это. картинка springArm1

While it may not eliminate instances of the camera penetrating objects in your level, depending on your Spring Arm’s settings, it will help reduce them by moving the camera’s position when it becomes obstructed automatically and then returning to its default position when it is free from obstruction.

Continuing from the Working with Camera Components How-to, open your Character Blueprint.

In the Components window, click the Add Component button then select the Spring Arm Component.

Spring arm ue4 что это. Spring1. Spring arm ue4 что это фото. Spring arm ue4 что это-Spring1. картинка Spring arm ue4 что это. картинка Spring1

Inside the Components window, drag your Camera Component onto the Spring Arm Component to attach it to the Spring Arm.

Spring arm ue4 что это. Spring2. Spring arm ue4 что это фото. Spring arm ue4 что это-Spring2. картинка Spring arm ue4 что это. картинка Spring2

There are multiple settings that can be used with the Spring Arm which are outlined below.

Spring arm ue4 что это. Spring4. Spring arm ue4 что это фото. Spring arm ue4 что это-Spring4. картинка Spring arm ue4 что это. картинка Spring4

Sockets

This allows you to parent the Spring Arm to a Bone on a Skeletal Mesh or a Socket.

Camera

Here you can set the length of the Spring Arm when there are no collisions as well as set Offsets.

Camera Collision

Set whether or not to check for collisions and define how big the query probe is to check for collisions.

Camera Settings

Whether or not to inherit Pitch, Yaw, or Roll from the Parent or Use Pawn Control Rotation.

Set whether or not the camera should lag behind the target position and settings associated with lag.

We set the Target Arm Length to 100 and Enabled Camera lag.

Spring arm ue4 что это. spring3. Spring arm ue4 что это фото. Spring arm ue4 что это-spring3. картинка Spring arm ue4 что это. картинка spring3

This gives us a shorter length than the default settings and also adds a bit of lag to the camera when moving around.

Click Compile and Play to play in the editor.

End Result

When moving the character, you will notice that the camera now lags slightly behind the characters movement. Also, when we move near a wall and rotate the camera, it attempts to reposition itself and moves in closer. When we are free from obstruction, it returns to its default length that we have specified in the settings.

Источник

Spring arm ue4 что это

В этом практическом руководстве по Unreal Engine будет добавлен компонент Spring Arm и родительский компонент Camera, чтобы наша камера могла приближаться или удаляться от персонажа в зависимости от игрового процесса. Как правило, когда вы добавляете компонент Camera к персонажу в целях создания перспективы от третьего лица, вы также захотите включить некий механизм, чтобы автоматически управлять тем, как камера обрабатывает ситуации, в которых ей мешает геометрия уровня или другие объекты в уровень.

Хотя это может не исключить все случаи проникновения камеры в объекты на вашем уровне, в зависимости от настроек вашего Spring Arm, это поможет уменьшить их, перемещая положение камеры, когда она перекрывается другими объектами, и затем возвращая ее в положение по умолчанию, когда препятствие остается позади.

Пошаговое руководство по добавлению Spring Arm в свой проект.

1. Откройте свой проект и выберите для редактирования Blueprint своего персонажа.

2. В окне Components нажмите кнопку Add Component, затем выберите компонент Spring Arm.

Spring arm ue4 что это. Spring1. Spring arm ue4 что это фото. Spring arm ue4 что это-Spring1. картинка Spring arm ue4 что это. картинка Spring1

3. В окне Components перетащите компонент Cmera на компонент Spring Arm для его привязки к Spring Arm.

Spring arm ue4 что это. Spring2. Spring arm ue4 что это фото. Spring arm ue4 что это-Spring2. картинка Spring arm ue4 что это. картинка Spring2

4. Есть несколько настроек, которые можно использовать с Spring Arm, они описаны ниже.

Spring arm ue4 что это. Spring4. Spring arm ue4 что это фото. Spring arm ue4 что это-Spring4. картинка Spring arm ue4 что это. картинка Spring4

НазваниеОписание
SocketsПозволяет привязать Spring Arm к Bone или к Skeletal Mesh, или к Socket.
CameraУказывается длина Spring Arm, когда нет столкновений, а также установить смещения.
Camera CollisionЗадается нужно ли проверять наличие коллизий и определить уровень проверка запроса для проверки коллизий.
Camera SettingsWhether or not to inherit Pitch, Yaw, or Roll from the Parent or Use Pawn Control Rotation.
LagУказывается должна ли камера отставать от заданной позиции и настроек, связанных с задержкой.

Spring arm ue4 что это. spring3. Spring arm ue4 что это фото. Spring arm ue4 что это-spring3. картинка Spring arm ue4 что это. картинка spring3

Это придвигает камеру ближе, чем настройки по умолчанию, а также добавляет немного задержки к камере при перемещении.

Конечный результат

Источник

Using Spring Arm Components

The Spring Arm component is used to automatically control how the camera handles situations where it becomes obstructed.

Choose your implementation method:

In this How-to tutorial, you will add a Spring Arm Component and parent it to a Camera Component. Spring Arm Components provide functionality to your camera so that it can expand or retract based on gameplay situations. Oftentimes, you may wish to add a camera to a character for the purposes of creating a third person perspective. It is usually recommended to include a Spring Arm to automatically control how the camera handles situations where it becomes obstructed by level geometry or other objects.

In this How-to tutorial, you will add a Spring Arm Component ( USpringArmComponent ) and parent it to a Camera Component. Spring Arm Components provide functionality to your camera so that it can expand or retract based on gameplay situations. Oftentimes, you may wish to add a camera to a character for the purposes of creating a third person perspective. It is usually recommended to include a Spring Arm to automatically control how the camera handles situations where it becomes obstructed by level geometry or other objects.

Spring arm ue4 что это. SpringArm shared1. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared1. картинка Spring arm ue4 что это. картинка SpringArm shared1

You can use your own character for this tutorial provided it has a Camera Component assigned to it. If you do not have a character, it is recommended that you first complete the Working with Camera Components tutorial in order to create the basic character being used in this guide.

While it may not eliminate all instances of the camera penetrating objects in your level, depending on your Spring Arm’s settings, it will help reduce them by automatically moving the camera’s position when it becomes obstructed and then returning to its default position when it is free from obstruction.

Creating the Spring Arm Component

Continuing from the Working with Camera Components How-to tutorial project, open your BP_CameraCharacter Blueprint.

In the Components tab, click the Add Component button then search and select the Spring Arm Component. Rename your component SpringArmComp.

Spring arm ue4 что это. SpringArm BP1. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP1. картинка Spring arm ue4 что это. картинка SpringArm BP1

Inside the Components tab, drag your CameraComp Component onto the Spring Arm Component to attach it.

Spring arm ue4 что это. SpringArm BP2. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP2. картинка Spring arm ue4 что это. картинка SpringArm BP2

With the SpringArmComp selected in the Components tab, navigate to the Details panel. There are multiple settings that can be used with the Spring Arm Component which are outlined below.

Sockets

Provide the capability to parent the Spring Arm to a Bone on a Skeletal Mesh or a Socket.

Camera

Set the length of the Spring Arm when there are no collisions as well as set Offsets.

Camera Collision

Set whether or not to check for collisions and define how big the query probe is to check for collisions.

Camera Settings

Set whether or not to inherit Pitch, Yaw, or Roll from the Parent or Use Pawn Control Rotation.

Set whether or not the camera should lag behind the target position and settings associated with lag.

In the Transform category, change the Location value to (0,0,150), then change the Rotation value to (0,0,90).

Spring arm ue4 что это. SpringArm shared2. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared2. картинка Spring arm ue4 что это. картинка SpringArm shared2

In the Camera Settings category, click the checkbox beside the Use Pawn Control Rotation variable, when enabled the Spring Arm Component‘s parent will use the view/control rotation of the pawn (your CameraCharacter).

Spring arm ue4 что это. SpringArm BP3. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP3. картинка Spring arm ue4 что это. картинка SpringArm BP3

In the Lag category, click the checkbox beside the Enable Camera Lag variable, when enabled the camera will lag behind the target position which will result in a smoother movement.

Spring arm ue4 что это. SpringArm BP4. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP4. картинка Spring arm ue4 что это. картинка SpringArm BP4

Next, in your ACameraCharacter::ACameraCharacter constructor declare the following code.

Compile your code.

From the Content Browser, double-click your BP_CameraCharacter to open it’s Class Defaults, then navigate to the Components tab, and select your SpringArmComp.

There are multiple settings that can be used with the Spring Arm Component which are outlined below.

Setting up Character Input

To demonstrate the functionality of your newly implemented Spring Arm Component, you will need to add movement input to your character class.

Begin by navigating to Edit > Project Settings >Engine > Input, then in the Bindings category, click the + sign next to Axis Mappings to create a new Axis input.

Spring arm ue4 что это. SpringArm shared3. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared3. картинка Spring arm ue4 что это. картинка SpringArm shared3

Name this Axis Mapping MoveForward, then search and select the W key value from the drop down key mapping menu.

Spring arm ue4 что это. SpringArm shared4. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared4. картинка Spring arm ue4 что это. картинка SpringArm shared4

Click the + sign next to the MoveForward Axis Mapping to add an additional key. From the drop down menu, search and select for the S key, then set the Scale value to -1.0.

Spring arm ue4 что это. SpringArm shared5. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared5. картинка Spring arm ue4 что это. картинка SpringArm shared5

Click the + sign next to Axis Mappings to create a new Axis input. Name this input MoveRight.

Spring arm ue4 что это. SpringArm shared6. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared6. картинка Spring arm ue4 что это. картинка SpringArm shared6

Click the + sign next to the MoveRight Axis Mapping to create an additional key, and set up your Move Right key mappings and Scales using the D and S keys with values of 1.0 and -1.0 respectively, as shown in the image below.

Spring arm ue4 что это. SpringArm shared7. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared7. картинка Spring arm ue4 что это. картинка SpringArm shared7

In the Bindings category, click the + sign next to Axis Mappings to create a new input named Turn, then search and select Mouse X for the input mapping key.

Spring arm ue4 что это. SpringArm shared8. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared8. картинка Spring arm ue4 что это. картинка SpringArm shared8

In the Bindings category, click the + sign next to Axis Mappings to create a new input named LookUp, then search and select Mouse Y for the input mapping key, and set it’s Scale value to -1.0.

Spring arm ue4 что это. SpringArm shared9. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared9. картинка Spring arm ue4 что это. картинка SpringArm shared9

Next, double click your BP_CameraCharacter and navigate to the Event Graph, right-click on the graph then search and select MoveForward for your Input Axis Event.

Spring arm ue4 что это. SpringArm BP5. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP5. картинка Spring arm ue4 что это. картинка SpringArm BP5

Click image to enlarge

Drag off the Execution pin of the InputAxis Move Forward node and in the drop down menu search for and select the Add Movement Input node, then drag off the Axis Value pin from the InputAxis Move Forward node and connect to the Scale Value pin of the Add Movement Input node.

Spring arm ue4 что это. SpringArm BP6. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP6. картинка Spring arm ue4 что это. картинка SpringArm BP6

Click image to enlarge

Right click on the Event Graph, in the context menu search for and select Get Control Rotation, then drag off from the Rotator Return Value pin and in the drop down menu search for and select Break Rotator.

Spring arm ue4 что это. SpringArm BP7. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP7. картинка Spring arm ue4 что это. картинка SpringArm BP7

Click image to enlarge

From the Break Rotator node, drag off the Z(Yaw) pin and in the drop down menu search for and select the Make Rotator node, then drag off the Rotator Return Value pin of the Make Rotator node and in the drop down menu search for and select Get Forward Vector.

Spring arm ue4 что это. SpringArm BP8. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP8. картинка Spring arm ue4 что это. картинка SpringArm BP8

Click image to enlarge

From the Get Forward Vector node, drag off the Vector Return Value pin and connect it to the Add Movement Input node’s World Direction pin.

Spring arm ue4 что это. SpringArm BP9. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP9. картинка Spring arm ue4 что это. картинка SpringArm BP9

Click image to enlarge

Right-click on the Event Graph again and search for and select Move Right for your Input Axis Event.

Spring arm ue4 что это. SpringArm BP10. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP10. картинка Spring arm ue4 что это. картинка SpringArm BP10

Click image to enlarge

Drag off the Execution pin from your InputAxis MoveRight node and in the drop down menu search for and select for the Add Movement Input node, then connect the Axis Value pin from the InputAxis MoveRight node into the Scale Value pin of the Add Movement Input node.

Spring arm ue4 что это. SpringArm BP11. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP11. картинка Spring arm ue4 что это. картинка SpringArm BP11

Click image to enlarge

From the Make Rotator node, drag off the Rotator Return Value pin and in the drop down menu search for and select the Get Right Vector node, then drag off the Vector Return Value pin and connect it to the Add Movement Input node’s World Direction pin.

Spring arm ue4 что это. SpringArm BP12. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP12. картинка Spring arm ue4 что это. картинка SpringArm BP12

Click image to enlarge

Your completed Movement Input Events will appear as shown in the image below.

Spring arm ue4 что это. SpringArm BP13. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP13. картинка Spring arm ue4 что это. картинка SpringArm BP13

Click image to enlarge

Right-click on the Event Graph, then search for and select the InputAxis LookUp event node, then right-click, search and select the Add Controller Pitch Input node.

Drag off from the Axis Value pin of the InputAxis LookUp node and connect to the Val pin of the Add Controller Pitch Input node. Drag off the execution output pin of the InputAxis LookUp node and connect to the execution input pin of the Add Controller Pitch Input node.

Spring arm ue4 что это. SpringArm BP14. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP14. картинка Spring arm ue4 что это. картинка SpringArm BP14

Click image to enlarge

Right-click on the Event Graph, then search for and select the Input Axis Turn event node, then right-click, search, and select the Add Controller Yaw Input node.

Drag off from the Axis Value pin of the Input Axis Turn node and connect to the Val pin of the Add Controller Yaw Input node. Drag off the execution output pin of the Input Axis Turn node and connect to the execution input pin of the Add Controller Yaw Input node.

Spring arm ue4 что это. SpringArm BP15. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP15. картинка Spring arm ue4 что это. картинка SpringArm BP15

Click image to enlarge

Click Compile and Save.

Spring arm ue4 что это. SpringArm BP16. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm BP16. картинка Spring arm ue4 что это. картинка SpringArm BP16

To demonstrate the functionality of your newly implemented Spring Arm Component, you will need to add movement input to your character class.

Begin by navigating to Edit > Project Settings >Engine > Input, then in the Bindings category, click the + sign next to Axis Mappings to create a new Axis input.

Spring arm ue4 что это. SpringArm shared3. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared3. картинка Spring arm ue4 что это. картинка SpringArm shared3

Name this Axis Mapping MoveForward, then search and select the W key value from the drop down key mapping menu.

Spring arm ue4 что это. SpringArm shared4. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared4. картинка Spring arm ue4 что это. картинка SpringArm shared4

Click the + sign next to the MoveForward Axis Mapping to add an additional key. From the drop down menu, search and select for the S key, then set the Scale value to -1.0.

Spring arm ue4 что это. SpringArm shared5. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared5. картинка Spring arm ue4 что это. картинка SpringArm shared5

Click the + sign next to Axis Mappings to create a new Axis input. Name this input MoveRight.

Spring arm ue4 что это. SpringArm shared6. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared6. картинка Spring arm ue4 что это. картинка SpringArm shared6

Click the + sign next to the MoveRight Axis Mapping to create an additional key, and set up your Move Right key mappings and Scales using the D and S keys with values of 1.0 and -1.0 respectively, as shown in the image below.

Spring arm ue4 что это. SpringArm shared7. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared7. картинка Spring arm ue4 что это. картинка SpringArm shared7

In the Bindings category, click the + sign next to Axis Mappings to create a new input named Turn, then search and select Mouse X for the input mapping key.

Spring arm ue4 что это. SpringArm shared8. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared8. картинка Spring arm ue4 что это. картинка SpringArm shared8

In the Bindings category, click the + sign next to Axis Mappings to create a new input named LookUp, then search and select Mouse Y for the input mapping key, and set it’s Scale value to -1.0.

Spring arm ue4 что это. SpringArm shared9. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared9. картинка Spring arm ue4 что это. картинка SpringArm shared9

Then in your CameraCharacter.cpp implement the following logic for your ACamerCharacter::MoveFoward, and ACameraCharacter::MoveRight class methods

Next, navigate to the ACameraCharacter::SetupPlayerInputComponent method, and implement the following code.

Level Setup

To demonstrate the functionality of the Spring Arm Component, you will need to place some geometrical obstructions into your level.

In the Editor, navigate to Window > Place Actors to open the Place Actors panel.

In the Place Actors panel, select the Geometry tab, and drag a Box Brush into your level.

Spring arm ue4 что это. SpringArm shared10. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared10. картинка Spring arm ue4 что это. картинка SpringArm shared10

Click image to enlarge

In the Details panel, you can adjust the bounds of your Box Brush by navigating to the Brush Settings category, and adjusting the X, Y, and Z values.

Spring arm ue4 что это. SpringArm shared11. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared11. картинка Spring arm ue4 что это. картинка SpringArm shared11

Click image to enlarge

Next, from the Toolbar press PIE(Play In Editor).

Spring arm ue4 что это. SpringArm shared12. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared12. картинка Spring arm ue4 что это. картинка SpringArm shared12

End Result

Spring arm ue4 что это. SpringArm shared13. Spring arm ue4 что это фото. Spring arm ue4 что это-SpringArm shared13. картинка Spring arm ue4 что это. картинка SpringArm shared13

When using WASD to move the character, you will notice that the camera now lags slightly behind the character’s movement. Also, when you navigate your character near a wall, the camera attempts to reposition itself and moves in closer. When the character is free from obstruction, the Spring Arm returns the camera to its default Target Arm Length that is specified in its default class properties.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *