@quenty/humanoidteleportutils 7.1.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [7.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/humanoidteleportutils@7.1.0...@quenty/humanoidteleportutils@7.2.0) (2023-12-28)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add HumanoidTeleportUtils.tryTeleportCharacter(character, position) ([db3f254](https://github.com/Quenty/NevermoreEngine/commit/db3f254213666f9e19183f917ae2e283d7b0e07b))
12
+
13
+
14
+
15
+
16
+
6
17
  # [7.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/humanoidteleportutils@7.0.0...@quenty/humanoidteleportutils@7.1.0) (2023-12-14)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/humanoidteleportutils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/humanoidteleportutils",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "description": "Utility for teleporting humanoids",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "2c2dbbc0cb2fbb46b4f3270c559c63890fe18b26"
34
+ "gitHead": "7440d02391695fa3e9c22f8c8285451ccfa32ad5"
35
35
  }
@@ -67,10 +67,38 @@ end
67
67
  @param position Vector3
68
68
  ]=]
69
69
  function HumanoidTeleportUtils.teleportRootPart(humanoid, rootPart, position)
70
+ assert(typeof(humanoid) == "Instance" and humanoid:IsA("Humanoid"), "Bad humanoid")
71
+ assert(typeof(rootPart) == "Instance" and rootPart:IsA("BasePart"), "Bad rootPart")
72
+ assert(typeof(position) == "Vector3", "Bad position")
73
+
70
74
  local offset = HumanoidTeleportUtils.getRootPartOffset(humanoid, rootPart)
71
75
  rootPart.CFrame = rootPart.CFrame - rootPart.Position + position + offset
72
76
  end
73
77
 
78
+ --[=[
79
+ Tries to teleport the character to a given position
80
+
81
+ @param character Model
82
+ @param position Vector3
83
+ ]=]
84
+ function HumanoidTeleportUtils.tryTeleportCharacter(character, position)
85
+ assert(typeof(character) == "Instance", "Bad character")
86
+ assert(typeof(position) == "Vector3", "Bad position")
87
+
88
+ local humanoid = character:FindFirstChildWhichIsA("Humanoid")
89
+ if not humanoid then
90
+ return false
91
+ end
92
+
93
+ local rootPart = humanoid.RootPart
94
+ if not rootPart then
95
+ return false
96
+ end
97
+
98
+ HumanoidTeleportUtils.teleportRootPart(humanoid, rootPart, position)
99
+ return true
100
+ end
101
+
74
102
  function HumanoidTeleportUtils.getRootPartOffset(humanoid, rootPart)
75
103
  -- Calculate additional offset for teleportation
76
104
  return Vector3.new(0, rootPart.Size.Y/2 + humanoid.HipHeight, 0)