Last active
December 5, 2023 18:28
-
-
Save SamatKadyrov/efc2733642e840af7a019a0bb47cd5ee to your computer and use it in GitHub Desktop.
Vector3 Static Methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Vector3StaticMethods : MonoBehaviour | |
{ | |
[SerializeField] private Vector3 _vector1 = new Vector3(1f, 0f, 0f); | |
[SerializeField] private Vector3 _vector2 = new Vector3(0f, 1f, 0f); | |
private float _angle; | |
private void Start() | |
{ | |
_angle = Vector3.Angle(_vector1, _vector2); | |
Debug.Log("Угол между вектором1 и вектором2: " + _angle); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Vector3Distance : MonoBehaviour | |
{ | |
[SerializeField] private Vector3 _vector1 = new Vector3(1f, 2f, 3f); | |
[SerializeField] private Vector3 _vector2 = new Vector3(4f, 5f, 6f); | |
private float _distance; | |
private void Start() | |
{ | |
_distance = Vector3.Distance(_vector1, _vector2); | |
Debug.Log("Расстояние между вектором1 и вектором2" + _distance); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Vector3Lerp : MonoBehaviour | |
{ | |
[SerializeField] private Vector3 _startPosition = new Vector3(0, 0, 0); | |
[SerializeField] private Vector3 _targetPosition = new Vector3(5, 3, 0); | |
[SerializeField] private float _stepCoefficient = 0.5f; // Коэффициент интерполяции | |
private Vector3 _newPosition; | |
private void Update() | |
{ | |
_newPosition = Vector3.Lerp(_startPosition, _targetPosition, _stepCoefficient); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Vector3Max : MonoBehaviour | |
{ | |
[SerializeField] private Vector3 _vector1 = new Vector3(1f, 2f, 3f); | |
[SerializeField] private Vector3 _vector2 = new Vector3(4f, 5f, 6f); | |
private Vector3 _maxVector3; | |
private void Start() | |
{ | |
_maxVector3 = Vector3.Max(_vector1, _vector2); | |
Debug.Log("Максимальный вектор: " + _maxVector3); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Vector3Min : MonoBehaviour | |
{ | |
[SerializeField] private Vector3 _vector1 = new Vector3(1f, 2f, 3f); | |
[SerializeField] private Vector3 _vector2 = new Vector3(4f, 5f, 6f); | |
private Vector3 _minVector; | |
private void Start() | |
{ | |
_minVector = Vector3.Min(_vector1, _vector2); | |
Debug.Log("Минимальный вектор: " + _minVector); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Vector3MoveTowards : MonoBehaviour | |
{ | |
[SerializeField] private Transform _obj; | |
[SerializeField] private float _maxDistance = 0.1f; | |
[SerializeField] private Vector3 _targetPosition = new Vector3(10, 5, 0); | |
private Vector3 _currentPosition; | |
private void Update() | |
{ | |
_currentPosition = _obj.transform.position; | |
_currentPosition = Vector3.MoveTowards(_currentPosition, _targetPosition, _maxDistance); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Vector3Normalize : MonoBehaviour | |
{ | |
[SerializeField] private Vector3 _vector = new Vector3(3f, 4f, 4f); | |
private Vector3 _normalizedVector; | |
private void Start() | |
{ | |
_normalizedVector = Vector3.Normalize(_vector); | |
Debug.Log("Нормализованный вектор: " + _normalizedVector); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Vector3Project : MonoBehaviour | |
{ | |
[SerializeField] private Vector3 _vector = new Vector3(3f, 4f, 0f); | |
[SerializeField] private Vector3 _normal = new Vector3(1f, 1f, 1f); | |
private Vector3 _projectedVector; | |
private void Start() | |
{ | |
_projectedVector = Vector3.Project(_vector, _normal); | |
Debug.Log("Проекция вектора: " + _projectedVector); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Vector3Reflect : MonoBehaviour | |
{ | |
[SerializeField] private Vector3 _vector1 = new Vector3(3f, 4f, 0f); | |
[SerializeField] private Vector3 _vector2 = new Vector3(1f, 1f, 1f); | |
private Vector3 _reflectedVector; | |
private void Start() | |
{ | |
_reflectedVector = Vector3.Reflect(_vector1, _vector2); | |
Debug.Log("Отраженный вектор: " + _reflectedVector); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Vector3StaticMethods : MonoBehaviour | |
{ | |
[SerializeField] private Transform _obj; | |
[SerializeField] private float _maxDistance = 0.1f; | |
[SerializeField] private Vector3 _targetPosition = new Vector3(10, 5, 0); | |
private Vector3 _currentPosition; | |
private void Update() | |
{ | |
_currentPosition = _obj.transform.position; | |
_currentPosition = Vector3.MoveTowards(_currentPosition, _targetPosition, _maxDistance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment