Last updated: Oct 19, 2022

Introduction

The Scope script is useful when attached to a weapon’s scope attachment so we can make sure that it is in fact a scope. It contains lots of variables that developers can edit to make sure each scope is different from the other!

You can find the Scope script ****at this path: Assets\Infima Games\Low Poly Animated - Modern Guns\Demo\Code\Attachments\Scope\Scope.cs

Fields Serialized

offset. Offset applied to the weapon bone when aiming through this scope.

fadeWhenNotAiming. Setting this value to true will make sure that this Scope has a fade material applied over it when not being aimed through, effectively darkening it.

fadeMaterial. Material used to represent a Scope that the player cannot see through. This gets applied to the renderer when the player isn’t aiming through this Scope.

fadeIndex. Index in the attachmentRenderer’s materials array of the Material that we want to replace for fadeMaterial when not aiming through this scope.

hideWhenScopeEquipped. If this value is true we will try to hide the material at fadeIndex by using fadeMaterial when the character isn’t aiming. This is very useful for things like sniper scopes that need to be kept dark whilst not aimed through.

attachmentRenderer. Reference to the MeshRenderer component that renders this scope mesh! It’d be very weird for us to have a scope with no mesh, so this basically always exists.

Functions

nonFadeMaterial. Represents the Material that is normally at fadeIndex in the attachmentRenderer’s sharedMaterials array.

gameModeService. Reference to the game's IGameModeService service.

Functions

GetOffset. Returns the offset this scope requires in order to be properly aimed.