Skip to content

Hoangvu-Itptit/SpringArmComponent

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status CodeFactor

platforms GitHub size

Recreation of Unreal's Spring Arm Component in Unity.

Spring Arm Component is a solution for cameras to expand/retract based on gameplay situations. Typically when you add a Camera to a character for the purposes of creating a third person perspective. Spring Arm automatically controls how the camera handles situations where it becomes obstructed by level geometry or other objects in the level.

Features

  • Multiple collision detection using Raycasts
  • Collision test resolution for different levels of preciseness
  • TPS camera movement integrated
  • Takes a minute to setup
  • Fully commented code for better understanding

Getting Started

Set the “Tool Handle Position” to Pivot mode for this to work correctly.

Image

Just drag and drop the SpringArm prefab from Prefabs folder to Hierarchy and delete your existing Main Camera or alternatively create a new GameObject, add SpringArm Script to it and make your Main Camera the child of this gameobject.

Image

Image

Usage

  • Target : The gameobject (Transform) which SpringArm has to follow.

  • Movement Smooth Time : The camera lag time while following the target.

  • Target Arm Length : Maximum distance to which the camera can move to behind the target. (Red line)

Image

  • Socket Offset : Offset for the camera from the SpringArm (Socket is the position where camera will be).

  • Target Offset : Offset of the SpringArm from the target.

  • Do Collision Test : Turn On or Off collision tests.

  • Collision Test Resolution : The count of rays raycasting from the SpringArm position to Camera position also referred as probe.

Image

Resolution - 4

Image

Resolution - 20

  • Collision Probe Size : Radius of collision (Green sphere).

Image

  • Collision Smooth Time : The camera lag time while moving for collision tests.

  • Collision Layer Mask : The layer mask for collision tests.

  • Use Control Rotation : To turn on/off the mouse input for rotation of the spring arm.

Note : All the gizmos shown in above images can be turned on/off for debugging
purposes under Debugging Header.

About

Recreation of Unreal's Spring Arm Component in Unity.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%