Skip to content

Commit f17ab31

Browse files
authored
Merge branch 'main' into new-3
2 parents ed84b7a + d7998a5 commit f17ab31

File tree

2 files changed

+245
-18
lines changed

2 files changed

+245
-18
lines changed
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
name: vector
2+
type: library
3+
summary: |
4+
A library of vector functions.
5+
description: |
6+
This library implements functionality for the vector type in addition to the built-in primitive operator support. It uses vectors with three components (`x`, `y`, and `z`).
7+
8+
Individual vector components can be accessed using the fields `x` or `X`, `y` or `Y`, `z` or `Z`. Since vector values are immutable, writing to individual components is not supported.
9+
code_samples:
10+
properties:
11+
- name: vector.zero
12+
type: vector
13+
summary: Constant vector with all components set to `0`.
14+
description: Constant vector with all components set to `0`.
15+
tags:
16+
code_samples:
17+
- name: vector.one
18+
type: vector
19+
summary: Constant vector with all components set to `1`.
20+
description: Constant vector with all components set to `1`.
21+
tags:
22+
code_samples:
23+
functions:
24+
- name: vector.create
25+
summary: Creates a new vector with the given component values.
26+
description: Creates a new vector with the given component values.
27+
parameters:
28+
- name: x
29+
type: number
30+
default:
31+
summary: ''
32+
- name: y
33+
type: number
34+
default:
35+
summary: ''
36+
- name: z
37+
type: number
38+
default:
39+
summary: ''
40+
returns:
41+
- type: vector
42+
summary: ''
43+
tags:
44+
code_samples:
45+
- name: vector.magnitude
46+
summary: Calculates the magnitude of a given vector.
47+
description: Calculates the magnitude of a given vector.
48+
parameters:
49+
- name: vec
50+
type: vector
51+
default:
52+
summary: ''
53+
returns:
54+
- type: number
55+
summary: ''
56+
tags:
57+
code_samples:
58+
- name: vector.normalize
59+
summary: Computes the normalized version (unit vector) of a given vector.
60+
description: Computes the normalized version (unit vector) of a given vector.
61+
parameters:
62+
- name: vec
63+
type: vector
64+
default:
65+
summary: ''
66+
returns:
67+
- type: vector
68+
summary: ''
69+
tags:
70+
code_samples:
71+
- name: vector.cross
72+
summary: Computes the cross product of two vectors.
73+
description: Computes the cross product of two vectors.
74+
parameters:
75+
- name: vec1
76+
type: vector
77+
default:
78+
summary: ''
79+
- name: vec2
80+
type: vector
81+
default:
82+
summary: ''
83+
returns:
84+
- type: vector
85+
summary: ''
86+
tags:
87+
code_samples:
88+
- name: vector.dot
89+
summary: Computes the dot product of two vectors.
90+
description: Computes the dot product of two vectors.
91+
parameters:
92+
- name: vec1
93+
type: vector
94+
default:
95+
summary: ''
96+
- name: vec2
97+
type: vector
98+
default:
99+
summary: ''
100+
returns:
101+
- type: number
102+
summary: ''
103+
tags:
104+
code_samples:
105+
- name: vector.angle
106+
summary: Computes the angle between two vectors in radians.
107+
description: |
108+
Computes the angle between two vectors in radians. The axis, if specified, is used to determine the sign of the angle.
109+
parameters:
110+
- name: vec1
111+
type: vector
112+
default:
113+
summary: ''
114+
- name: vec2
115+
type: vector
116+
default:
117+
summary: ''
118+
- name: axis
119+
type: vector?
120+
default:
121+
summary: ''
122+
returns:
123+
- type: number
124+
summary: ''
125+
tags:
126+
code_samples:
127+
- name: vector.floor
128+
summary: Applies `Library.math.floor()` to every component of the input vector.
129+
description: Applies `Library.math.floor()` to every component of the input vector.
130+
parameters:
131+
- name: vec
132+
type: vector
133+
default:
134+
summary: ''
135+
returns:
136+
- type: vector
137+
summary: ''
138+
tags:
139+
code_samples:
140+
- name: vector.ceil
141+
summary: Applies `Library.math.ceil()` to every component of the input vector.
142+
description: Applies `Library.math.ceil()` to every component of the input vector.
143+
parameters:
144+
- name: vec
145+
type: vector
146+
default:
147+
summary: ''
148+
returns:
149+
- type: vector
150+
summary: ''
151+
tags:
152+
code_samples:
153+
- name: vector.abs
154+
summary: Applies `Library.math.abs()` to every component of the input vector.
155+
description: Applies `Library.math.abs()` to every component of the input vector.
156+
parameters:
157+
- name: vec
158+
type: vector
159+
default:
160+
summary: ''
161+
returns:
162+
- type: vector
163+
summary: ''
164+
tags:
165+
code_samples:
166+
- name: vector.sign
167+
summary: Applies `Library.math.sign()` to every component of the input vector.
168+
description: Applies `Library.math.sign()` to every component of the input vector.
169+
parameters:
170+
- name: vec
171+
type: vector
172+
default:
173+
summary: ''
174+
returns:
175+
- type: vector
176+
summary: ''
177+
tags:
178+
code_samples:
179+
- name: vector.clamp
180+
summary: Applies `Library.math.clamp()` to every component of the input vector.
181+
description: Applies `Library.math.clamp()` to every component of the input vector.
182+
parameters:
183+
- name: vec
184+
type: vector
185+
default:
186+
summary: ''
187+
- name: min
188+
type: vector
189+
default:
190+
summary: ''
191+
- name: max
192+
type: vector
193+
default:
194+
summary: ''
195+
returns:
196+
- type: vector
197+
summary: ''
198+
tags:
199+
code_samples:
200+
- name: vector.max
201+
summary: Applies `Library.math.max()` to the corresponding components of the input vectors.
202+
description: |
203+
Applies `Library.math.max()` to the corresponding components of the input vectors.
204+
parameters:
205+
- name: ...
206+
type: vector
207+
default:
208+
summary: ''
209+
returns:
210+
- type: vector
211+
summary: ''
212+
tags:
213+
code_samples:
214+
- name: vector.min
215+
summary: Applies `Library.math.min()` to the corresponding components of the input vectors.
216+
description: |
217+
Applies `Library.math.min()` to the corresponding components of the input vectors.
218+
parameters:
219+
- name: ...
220+
type: vector
221+
default:
222+
summary: ''
223+
returns:
224+
- type: vector
225+
summary: ''
226+
tags:
227+
code_samples:

content/en-us/workspace/collisions.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -262,27 +262,27 @@ interesting but unintended gameplay, such as characters jumping on top of each o
262262
local PhysicsService = game:GetService("PhysicsService")
263263
local Players = game:GetService("Players")
264264

265-
PhysicsService:RegisterCollisionGroup("Characters")
266-
PhysicsService:CollisionGroupSetCollidable("Characters", "Characters", false)
267-
268-
local function onDescendantAdded(descendant)
269-
-- Set collision group for any part descendant
270-
if descendant:IsA("BasePart") then
271-
descendant.CollisionGroup = "Characters"
265+
local CollisionGroupName = "Characters"
266+
PhysicsService:RegisterCollisionGroup(CollisionGroupName)
267+
PhysicsService:CollisionGroupSetCollidable(CollisionGroupName, CollisionGroupName, false)
268+
269+
local function setCollisionGroup(model)
270+
-- Apply collision group to all existing parts in the model
271+
for _, descendant in model:GetDescendants() do
272+
if descendant:IsA("BasePart") then
273+
descendant.CollisionGroup = CollisionGroupName
274+
end
272275
end
273276
end
274277

275-
local function onCharacterAdded(character)
276-
-- Process existing and new descendants for physics setup
277-
for _, descendant in character:GetDescendants() do
278-
onDescendantAdded(descendant)
279-
end
280-
character.DescendantAdded:Connect(onDescendantAdded)
281-
end
282-
283278
Players.PlayerAdded:Connect(function(player)
284-
-- Detect when the player's character is added
285-
player.CharacterAdded:Connect(onCharacterAdded)
279+
player.CharacterAdded:Connect(function(character)
280+
setCollisionGroup(character)
281+
end)
282+
-- If the player already has a character, apply the collision group immediately
283+
if player.Character then
284+
setCollisionGroup(player.Character)
285+
end
286286
end)
287287
```
288288

@@ -360,4 +360,4 @@ The `Class.TriangleMeshPart.CollisionFidelity|CollisionFidelity` property has th
360360
To view collision fidelity in Studio, toggle on **Collision fidelity** from the [Visualization Options](../studio/ui-overview.md#visualization-options) widget in the upper‑right corner of the 3D viewport.
361361
</Alert>
362362

363-
For more information on the performance impact of collision fidelity options and how to mitigate them, see [Performance Optimization](../performance-optimization/improving.md#physics-computation). For an in‑depth walkthrough on how to choose a collision fidelity option that balances your precision needs and performance requirements, see [here](../tutorials/environmental-art/assemble-an-asset-library.md#collisionfidelity).
363+
For more information on the performance impact of collision fidelity options and how to mitigate them, see [Performance Optimization](../performance-optimization/improving.md#physics-computation).

0 commit comments

Comments
 (0)