-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelper.cs
More file actions
22 lines (20 loc) · 715 Bytes
/
Helper.cs
File metadata and controls
22 lines (20 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class Helper {
/// <summary>
/// Returns a vector between two points
/// </summary>
/// <param name="p1">Point 1</param>
/// <param name="p2">Point 2</param>
public static Vector3 VectorBetweenPoints(Vector3 p1, Vector3 p2)
{
// Calculate Angle Between the collision point and the player
Vector3 dir = p1 - p2;
// We then get the opposite (-Vector3) and normalize it
dir = -dir.normalized;
// And finally we add force in the direction of dir and multiply it by force.
// This will push back the player
return dir;
}
}