Programming Language: C# (CSharp)

Namespace/Package Name: System

Class/Type: Vector3

Method/Function: Extend

Examples at hotexamples.com: 30

The System Vector3 Extend is a function that allows you to extend the Vector3 object by adding a given distance to its magnitude. This function can be useful in many scenarios, such as when you want to increase the length of a vector to reach a certain point, or when you need to push an object away from a certain location.

Examples:

1. To extend a vector by a certain distance:

2. To push an object away from a certain position:

Examples:

1. To extend a vector by a certain distance:

Vector3 originalVector = new Vector3(1, 0, 0); float distanceToExtend = 2f; Vector3 extendedVector = originalVector.Extend(distanceToExtend); // The extendedVector will now have a magnitude of 3 (the originalVector's length was 1)

2. To push an object away from a certain position:

Vector3 objectPosition = transform.position; Vector3 targetPosition = new Vector3(10, 5, 0); float pushDistance = 2f; Vector3 pushDirection = (objectPosition - targetPosition).normalized; transform.position = objectPosition + pushDirection.Extend(pushDistance); // The object will now be pushed away from the target position by 2 unitsPackage library: The System Vector3 Extend function is part of the Unity engine's core libraries. Therefore, it is part of the UnityEngine namespace and does not require any additional packages or libraries.

Frequently Used Methods

Frequently Used Methods

Frequently Used Methods

Related in langs

Frequently Used Methods

Related