forked from Roblox/creator-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorldRoot.yaml
More file actions
1080 lines (1033 loc) · 41 KB
/
WorldRoot.yaml
File metadata and controls
1080 lines (1033 loc) · 41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: WorldRoot
type: class
category:
memory_category: PhysicsParts
summary: |
Base class for handling physics simulation and 3D spatial queries.
description: |
This base class provides an API for any instance intended for handling 3D
spatial queries and simulation, such as `Class.Workspace` and
`Class.WorldModel`.
code_samples:
inherits:
- Model
tags:
- NotCreatable
deprecation_message: ''
properties: []
methods:
- name: WorldRoot:ArePartsTouchingOthers
summary: |
Returns true if any of the given `Class.BasePart` are touching any other
parts.
description: |
**ArePartsTouchingOthers** returns true if at least one of the given
`Class.BasePart` are touching any other parts. Two parts are considered
"touching" if they are within the distance threshold, `overlapIgnored`.
If no parts are provided, false is returned.
code_samples:
- checking-for-touching-parts
parameters:
- name: partList
type: Instances
default:
summary: |
A list of parts checks to see if any parts in the list are touching
any parts not in the list.
- name: overlapIgnored
type: float
default: 0.000199999995
summary: |
The part overlap threshold in studs that is ignored before parts are
considered to be touching.
returns:
- type: bool
summary: |
True if and only if any of the `Class.Part|parts` in `partList` are
touching any other parts (parts not in the partList). False if no
parts are passed.
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities: []
writeCapabilities: []
- name: WorldRoot:Blockcast
summary: |
Casts a block shape in a given direction and returns a
`Datatype.RaycastResult` if the shape hits a `Class.BasePart` or
`Class.Terrain` cell.
description: |
Casts a block shape in a given direction and returns the first collision
with a `Class.BasePart` or `Class.Terrain` cell. This is analogous to how
`Class.WorldRoot:Raycast()` casts a linear ray in a direction to find a
collision, but it uses a 3D shape instead of a ray.
Unlike `Class.WorldRoot:GetPartsInPart()`, this method does not detect
`Class.BasePart|BaseParts` that **initially** intersect the shape.
If a hit is detected, a `Datatype.RaycastResult` is returned containing
the hit information. The `Datatype.RaycastResult.Distance|Distance`
property represents the distance the shape has to travel to find a hit,
and the `Datatype.RaycastResult.Position|Position` property represents the
intersection point that causes the hit.
This method throws an error if it is passed invalid `Datatype.CFrame`,
size, or direction inputs.
code_samples:
- worldroot---blockcast
parameters:
- name: cframe
type: CFrame
default:
summary: |
The initial position and rotation of the cast block shape.
- name: size
type: Vector3
default:
summary: |
The size of the cast block shape in studs. The maximum size is 512
studs.
- name: direction
type: Vector3
default:
summary: |
Direction of the shapecast, with the magnitude representing the
maximum distance the shape can travel. The maximum distance is 1024
studs.
- name: params
type: RaycastParams
default: RaycastParams{IgnoreWater=false, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}
summary: ''
returns:
- type: RaycastResult?
summary: |
Contains the result of the shapecast operation, or `nil` if no
eligible `Class.BasePart` or `Class.Terrain` cell was hit.
tags: []
deprecation_message: ''
security: None
thread_safety: Safe
capabilities: []
writeCapabilities: []
- name: WorldRoot:BulkMoveTo
summary: |
Moves a table of `Class.BasePart|BaseParts` to a table of
`Datatype.CFrame|CFrames`.
description: |
This function moves a table of `Class.BasePart|BaseParts` to a table of
`Datatype.CFrame|CFrames` without necessarily firing the default property
`Class.Object.Changed|Changed` events. This provides a very fast way to
move large numbers of parts, as you don't have to pay the cost of separate
property sets for each individual part.
The third argument allows you to further optimize the movement operation.
By default, the `Class.Object.Changed|Changed` event of each part fires
for `Class.BasePart.Position|Position`,
`Class.BasePart.Orientation|Orientation`, and
`Class.BasePart.CFrame|CFrame`. However, if you specify
`Enum.BulkMoveMode|FireCFrameChanged` as the third argument, only the
`Class.Object.Changed|Changed` event for the
`Class.BasePart.CFrame|CFrame` property will fire.
Note that you should only use this function if you're sure that part
movement is a bottleneck in your code. Simply setting the
`Class.BasePart.CFrame|CFrame` property of individual parts and welded
models is fast enough in the majority of cases.
code_samples:
parameters:
- name: partList
type: Instances
default:
summary: ''
- name: cframeList
type: Array
default:
summary: ''
- name: eventMode
type: BulkMoveMode
default: FireAllEvents
summary: ''
returns:
- type: void
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities: []
writeCapabilities: []
- name: WorldRoot:FindPartOnRay
summary: |
Returns the first `Class.BasePart` or `Class.Terrain` cell intersecting
with the given `Datatype.Ray`.
description: |
**FindPartOnRay** uses [raycasting](../../../workspace/raycasting.md) to
find the first `Class.BasePart` or `Class.Terrain` cell intersecting with
a given `Datatype.Ray`. This function returns the `Class.BasePart` or
terrain cell hit, the point of intersection, the surface normal at the
point of intersection, and the associated `Enum.Material` hit.
If the `ignoreDescendantsInstance` parameter is provided, the raycasting
calculation will ignore the given object and all of its descendants. It
behaves similar to the `Class.Mouse.TargetFilter` property.
The `terrainCellsAreCubes` and `ignoreWater` parameters determine whether
`Class.Terrain` cells should be treated as cubes or not, and whether water
should be ignored or not.
In order to include or exclude multiple objects and their descendants, use
the `Class.WorldRoot:FindPartOnRayWithWhitelist()` and
`Class.WorldRoot:FindPartOnRayWithIgnoreList()` variants.
#### Notes
- Theoretically, a ray extends infinitely in one direction. However, the
max length of the direction vector on Roblox is 15000 studs.
- The length (magnitude) of the directional vector is important, as parts
further away than its length will not be tested.
- If the ray does not intersect anything, the return values will be `nil`
and the point at the end of the ray, respectively.
- Parts that are in a
[collision group](../../../workspace/collisions.md#collision-filtering)
that does not collide with the "Default" collision group are ignored
implicitly.
code_samples:
parameters:
- name: ray
type: Ray
default:
summary: ''
- name: ignoreDescendantsInstance
type: Instance
default: nil
summary: ''
- name: terrainCellsAreCubes
type: bool
default: false
summary: ''
- name: ignoreWater
type: bool
default: false
summary: ''
returns:
- type: Tuple
summary: |
The `Class.BasePart` or `Class.Terrain` cell hit, the
`Datatype.Vector3` point of intersection, the `Datatype.Vector3`
surface normal at the point of intersection, and the `Enum.Material`
of the `Class.BasePart` or terrain cell hit.
tags:
- Deprecated
deprecation_message: |
This function has been deprecated. Use `Class.WorldRoot:Raycast()` along
with `Datatype.RaycastParams` for new work.
security: None
thread_safety: Unsafe
capabilities: []
writeCapabilities: []
- name: WorldRoot:FindPartOnRayWithIgnoreList
summary: |
Returns the first `Class.BasePart` or `Class.Terrain` cell intersecting
with the given `Datatype.Ray` that isn't in, nor is a descendant of an
object in, the given ignore list.
description: |
This function is a variant of `Class.WorldRoot:FindPartOnRay()` with the
addition of an ignore list. This lets you ignore certain parts or
`Class.Model|Models`.
Those looking to **include** a specific group of objects should instead
use `Class.WorldRoot:FindPartOnRayWithWhitelist()`.
code_samples:
parameters:
- name: ray
type: Ray
default:
summary: ''
- name: ignoreDescendantsTable
type: Instances
default:
summary: ''
- name: terrainCellsAreCubes
type: bool
default: false
summary: ''
- name: ignoreWater
type: bool
default: false
summary: ''
returns:
- type: Tuple
summary: |
The `Class.BasePart` or `Class.Terrain` cell hit, the
`Datatype.Vector3` point of intersection, the `Datatype.Vector3`
surface normal at the point of intersection, and the `Enum.Material`
of the `Class.BasePart` or terrain cell hit.
tags:
- Deprecated
deprecation_message: |
This function has been deprecated. Use `Class.WorldRoot:Raycast()` along
with `Datatype.RaycastParams` for new work.
security: None
thread_safety: Unsafe
capabilities: []
writeCapabilities: []
- name: WorldRoot:FindPartOnRayWithWhitelist
summary: |
Returns the first `Class.BasePart` or `Class.Terrain` cell intersecting
with the given `Datatype.Ray` that is in, or is a descendant of an object
in, the given inclusion list.
description: |
This function is a variant of `Class.WorldRoot:FindPartOnRay()` with the
addition of an inclusion list. This lets you detect only certain parts or
`Class.Model|Models` and is particularly useful when, for example, looking
for points of intersection between a ray and a single part.
If a `nil` value is given in the inclusion list, instances after it will
be disregarded.
Those looking to **exclude** a specific group of objects should instead
use `Class.WorldRoot:FindPartOnRayWithIgnoreList()`.
code_samples:
parameters:
- name: ray
type: Ray
default:
summary: ''
- name: whitelistDescendantsTable
type: Instances
default:
summary: ''
- name: ignoreWater
type: bool
default: false
summary: ''
returns:
- type: Tuple
summary: |
The `Class.BasePart` or `Class.Terrain` cell hit, the
`Datatype.Vector3` point of intersection, the `Datatype.Vector3`
surface normal at the point of intersection, and the `Enum.Material`
of the `Class.BasePart` or terrain cell hit.
tags:
- Deprecated
deprecation_message: |
This function has been deprecated. Use `Class.WorldRoot:Raycast()` along
with `Datatype.RaycastParams` for new work.
security: None
thread_safety: Unsafe
capabilities: []
writeCapabilities: []
- name: WorldRoot:FindPartsInRegion3
summary: |
Returns an array of `Class.BasePart|BaseParts` in the given
`Datatype.Region3`.
description: |
Returns an array of `Class.BasePart|BaseParts` in the given
`Datatype.Region3`.
This function takes an optional maxParts parameter (default 20) which
limits the number of `Class.BasePart|BaseParts` that can be returned. Once
this number has been reached, the search for `Class.BasePart|BaseParts`
will stop. This means some `Class.BasePart|BaseParts` may not be returned
even if they are within the `Datatype.Region3`
The optional `ignoreDescendantsInstance` parameter can be used to specify
a specific instance for whom itself and all of its descendants should be
ignored by this function. This can be useful when, for example, looking to
see if any `Class.BasePart|BaseParts` are inside a `Class.BasePart` other
than the `Class.BasePart` itself.
```
local min = part.Position - (0.5 * part.Size)
local max = part.Position + (0.5 * part.Size)
local region = Region3.new(min, max)
local parts = worldroot:FindPartsInRegion3(region, part) -- Ignore part
```
The `Class.WorldRoot:FindPartsInRegion3WithIgnoreList()` and
`Class.WorldRoot:FindPartsInRegion3WithWhiteList()` variants of this
method exist to provide specific exclusion and inclusion functionality.
If no `Class.BasePart|BaseParts` are found, an empty array will be
returned.
code_samples:
parameters:
- name: region
type: Region3
default:
summary: |
The `Datatype.Region3` to be checked.
- name: ignoreDescendantsInstance
type: Instance
default: nil
summary: |
An `Class.Instance` to be ignored.
- name: maxParts
type: int
default: 20
summary: |
The maximum amount of `Class.BasePart|BaseParts` to be returned.
returns:
- type: Instances
summary: |
An array of `Class.BasePart|BaseParts` within the `Datatype.Region3`.
tags:
- Deprecated
deprecation_message: |
This function has been deprecated. Use
`Class.WorldRoot:GetPartBoundsInBox()` along with `Datatype.OverlapParams`
for new work.
security: None
thread_safety: Unsafe
capabilities: []
writeCapabilities: []
- name: WorldRoot:FindPartsInRegion3WithIgnoreList
summary: |
Returns an array of `Class.BasePart|BaseParts` in the given
`Datatype.Region3` that aren't in, or a descendant of an entry in, the
given ignore list.
description: |
Returns an array of `Class.BasePart|BaseParts` in the given
`Datatype.Region3` that aren't in, or a descendant of an entry in, the
given ignore list.
If a `nil` value is given in the ignore list, instances after this value
will not be ignored. If no `Class.BasePart|BaseParts` are found, an empty
array will be returned.
This function is a variant of `Class.WorldRoot:FindPartsInRegion3()` with
the addition of an ignore list. This allows the developer to exclude
certain `Class.BasePart|BaseParts` or `Class.Model|Models` from the
search. Those looking to find `Class.BasePart|BaseParts` in a
`Datatype.Region3` using an inclusion list should use
`Class.WorldRoot:FindPartsInRegion3WithWhiteList()`.
code_samples: []
parameters:
- name: region
type: Region3
default:
summary: |
The `Datatype.Region3` to be checked.
- name: ignoreDescendantsTable
type: Instances
default:
summary: |
An array of objects to be ignored.
- name: maxParts
type: int
default: 20
summary: |
The maximum number of `Class.BasePart|BaseParts` to be returned.
returns:
- type: Instances
summary: |
An array of `Class.BasePart|BaseParts` found within the
`Datatype.Region3`.
tags:
- Deprecated
deprecation_message: |
This function has been deprecated. Use
`Class.WorldRoot:GetPartBoundsInBox()` along with `Datatype.OverlapParams`
for new work.
security: None
thread_safety: Unsafe
capabilities: []
writeCapabilities: []
- name: WorldRoot:FindPartsInRegion3WithWhiteList
summary: |
Returns an array of `Class.BasePart|BaseParts` in the given
`Datatype.Region3` that are in, or descendant of an entry in, the given
inclusion list.
description: |
Returns an array of `Class.BasePart|BaseParts` in the given
`Datatype.Region3` that are in, or descendant of an entry in, the given
inclusion list.
If a `nil` value is given in the inclusion list, instances after this
value will not be ignored. If no `Class.BasePart|BaseParts` are found, an
empty array will be returned.
This function is a variant of `Class.WorldRoot:FindPartsInRegion3()` with
the addition of an inclusion list. This allows the developer to include
only certain `Class.BasePart|BaseParts` or `Class.Model|Models` in the
search. Those looking to find `Class.BasePart|BaseParts` in a
`Datatype.Region3` using an exclusion list should use
`Class.WorldRoot:FindPartsInRegion3WithIgnoreList()`.
code_samples: []
parameters:
- name: region
type: Region3
default:
summary: |
The `Datatype.Region3` to be checked.
- name: whitelistDescendantsTable
type: Instances
default:
summary: |
An array of objects to check.
- name: maxParts
type: int
default: 20
summary: |
The maximum number of `Class.BasePart|BaseParts` to be returned.
returns:
- type: Instances
summary: |
An array of `Class.BasePart|BaseParts` within the `Datatype.Region3`.
tags:
- Deprecated
deprecation_message: |
This function has been deprecated. Use
`Class.WorldRoot:GetPartBoundsInBox()` along with `Datatype.OverlapParams`
for new work.
security: None
thread_safety: Unsafe
capabilities: []
writeCapabilities: []
- name: WorldRoot:GetPartBoundsInBox
summary: |
Returns an array of parts whose **bounding boxes** overlap a given box.
description: |
`Class.WorldRoot:GetPartBoundsInBox()` returns an array of parts whose
**bounding boxes** overlap a box whose volume is described using the given
center (`Datatype.CFrame`) and size (`Datatype.Vector3`).
As emphasized, this spatial query method efficiently considers the volume
of parts' bounding boxes rather than their actual occupied volume. This
may be important when considering cylinders, spheres, unions, and
`Class.MeshPart|MeshParts` which have non-block shapes. For cases where
accuracy especially matters, use `Class.WorldRoot:GetPartsInPart()`
instead, or further filter the results of this method yourself.
This method uses a `Datatype.OverlapParams` object to describe reusable
portions of the spatial query, such as an inclusion or exclusion list, the
maximum number of parts to query, what
[collision group](../../../workspace/collisions.md#collision-filtering) to
use, and whether the query favors an intersected part's
`Class.BasePart.CanCollide` value over its `Class.BasePart.CanQuery`
value.
code_samples:
parameters:
- name: cframe
type: CFrame
default:
summary: |
The location of the center of the given box volume to be queried.
- name: size
type: Vector3
default:
summary: |
The size of the given box volume to be queried.
- name: overlapParams
type: OverlapParams
default: OverlapParams{MaxParts=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}
summary: |
Contains reusable portions of the spatial query parameters.
returns:
- type: Instances
summary: |
An array of `Class.BasePart|BaseParts` which matched the spatial
query.
tags: []
deprecation_message: ''
security: None
thread_safety: Safe
capabilities: []
writeCapabilities: []
- name: WorldRoot:GetPartBoundsInRadius
summary: |
Returns an array of parts whose **bounding boxes** overlap a given sphere.
description: |
`Class.WorldRoot:GetPartBoundsInRadius()` returns an array of parts whose
**bounding boxes** overlap a sphere whose volume is described using the
given center (`Datatype.Vector3`) and radius (number).
As emphasized, this spatial query method efficiently considers the volume
of parts' bounding boxes rather than their actual occupied volume. This
may be important when considering cylinders, spheres, unions, and
`Class.MeshPart|MeshParts` which have non-block shapes. For cases where
accuracy especially matters, use `Class.WorldRoot:GetPartsInPart()`
instead, or further filter the results of this method yourself.
This method uses a `Datatype.OverlapParams` object to describe reusable
portions of the spatial query, such as an inclusion or exclusion list, the
maximum number of parts to query, what
[collision group](../../../workspace/collisions.md#collision-filtering) to
use, and whether the query favors an intersected part's
`Class.BasePart.CanCollide` value over its `Class.BasePart.CanQuery`
value.
code_samples:
parameters:
- name: position
type: Vector3
default:
summary: |
The location of the center of the given sphere volume to be queried.
- name: radius
type: float
default:
summary: |
The radius of the given sphere volume to be queried.
- name: overlapParams
type: OverlapParams
default: OverlapParams{MaxParts=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}
summary: |
Contains reusable portions of the spatial query parameters.
returns:
- type: Instances
summary: |
An array of `Class.BasePart|BaseParts` which matched the spatial
query.
tags: []
deprecation_message: ''
security: None
thread_safety: Safe
capabilities: []
writeCapabilities: []
- name: WorldRoot:GetPartsInPart
summary: |
Returns an array of parts whose occupied space is shared with the given
part.
description: |
`Class.WorldRoot:GetPartsInPart()` returns an array of parts whose
occupied space is shared with the given part (which must exist in the same
`Class.WorldRoot` as the parts to be queried). This method can be used in
place of `Class.BasePart:GetTouchingParts()` and is generally a better
choice.
As noted, this spatial query method considers the **exact volume**
occupied by the given part using a full geometric collision check. As an
example, a concave/hollow part won't match queried parts within it unless
they actually overlap/touch such a part. For simpler volumes, consider
using `Class.WorldRoot:GetPartBoundsInBox()` or
`Class.WorldRoot:GetPartBoundsInRadius()`, as they are less accurate but
perform more efficiently.
This method uses a `Datatype.OverlapParams` object to describe reusable
portions of the spatial query, such as an inclusion or exclusion list, the
maximum number of parts to query, what
[collision group](../../../workspace/collisions.md#collision-filtering) to
use, and whether the query favors an intersected part's
`Class.BasePart.CanCollide` value over its `Class.BasePart.CanQuery`
value.
code_samples:
parameters:
- name: part
type: BasePart
default:
summary: |
The part whose volume is to be checked against other parts.
- name: overlapParams
type: OverlapParams
default: OverlapParams{MaxParts=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}
summary: |
Contains reusable portions of the spatial query parameters.
returns:
- type: Instances
summary: |
An array of `Class.BasePart|BaseParts` which matched the spatial
query.
tags: []
deprecation_message: ''
security: None
thread_safety: Safe
capabilities: []
writeCapabilities: []
- name: WorldRoot:IKMoveTo
summary: |
Moves the specified part to the specified location via inverse kinematics
rather than moving it there directly, to ensure any joints, constraints,
or collisions that part is participating in remain physically satisfied.
description: |
This function moves the specified part to the specified location via
[inverse kinematics](https://en.wikipedia.org/wiki/Inverse_kinematics)
rather than moving it there directly, to ensure any joints,
`Class.Constraint|constraints`, or collisions that part is participating
in remain physically satisfied. Currently this function is only available
in Studio to `Class.Plugin|plugins`, as it currently conflicts with the
physics of a running game.
**Translate stiffness** is a number between 0 and 1 specifying how
aggressively to match the part's position to the position part of the
target CFrame. **Rotate stiffness** is a number between 0 and 1 specifying
how aggressively to match the part's rotation to the rotation part of the
target CFrame.
For example:
- If translate stiffness and rotate stiffness are both equal to 1, then
the part will be moved exactly to the target CFrame regardless of what
physical constraints there are on it.
- If translate stiffness and rotate stiffness are both equal to 0.5, then
the part will try to move to exactly the target CFrame, but may be
pushed out of the way by physical constraints on it.
- If translate stiffness and rotate stiffness are both equal to 0, then
the target CFrame will be ignored and physical constraints will be
solved for the object at the position where it was.
code_samples:
parameters:
- name: part
type: BasePart
default:
summary: |
The part being moved.
- name: target
type: CFrame
default:
summary: |
The location to move the specified part.
- name: translateStiffness
type: float
default: 0.5
summary: |
A number between 0 and 1 specifying how aggressively to match the
part's position to the position part of the target `Datatype.CFrame`.
- name: rotateStiffness
type: float
default: 0.5
summary: |
A number between 0 and 1 specifying how aggressively to match the
part's rotation to the rotation part of the target `Datatype.CFrame`.
- name: collisionsMode
type: IKCollisionsMode
default: OtherMechanismsAnchored
summary: |
Allows you to specify what objects should be effected by the physical
resolution.
returns:
- type: void
summary: ''
tags: []
deprecation_message: ''
security: PluginSecurity
thread_safety: Unsafe
capabilities: []
writeCapabilities: []
- name: WorldRoot:IsRegion3Empty
summary: |
Returns a bool indicating whether there are no `Class.BasePart|BaseParts`
within the given `Datatype.Region3`.
description: |
**IsRegion3Empty** returns a bool indicating whether there are no
`Class.BasePart|BaseParts` within the given `Datatype.Region3`.
The optional `ignoreDescendantsInstance` parameter can be used to specify
a specific instance for whom itself and all of its descendants should be
ignored by this function. This can be useful when, for example, looking to
see if any `Class.BasePart|BaseParts` are inside a `Class.BasePart` other
than the `Class.BasePart` itself.
```
local min = part.Position - (0.5 * part.Size)
local max = part.Position + (0.5 * part.Size)
local region = Region3.new(min, max)
local isPartEmpty = worldroot:IsRegion3Empty(region, part) -- Ignore part
```
If more than one object and its descendants need to be excluded from the
search, developers should use
`Class.WorldRoot:IsRegion3EmptyWithIgnoreList()`.
This function only returns if a region is empty or not. Developers looking
to find `Class.BasePart|BaseParts` in a region should use
`Class.WorldRoot:FindPartsInRegion3()`.
#### How do Region3 checks work?
Checking if a part overlaps a `Datatype.Region3` is not a simple process.
It actually is time consuming and complicated. Instead it checks if parts
are roughly in the same area. When this function is called, it figures out
which voxels contain the `Datatype.Region3`. It then figures out which
parts might be in those voxels. It does this by comparing the axis-aligned
bounding box (sometimes called the AABB) of the part with the voxels. The
axis-aligned bounding box can be seen in Roblox Studio when a part is
selected.
This means that the area that is inspected by the function may be larger
than the `Datatype.Region3`. For this reason it is recommended to make
sure that the `Datatype.Region3` is on the voxel grid. The best way to do
this is by setting the coordinates of the `Datatype.Region3` to multiples
of 4 (since voxels are 4 x 4 x 4 studs).
This method is a fairly quick and easy way to see if any parts are in a
general area. If a game needs to know if parts are exactly in an area,
then `Class.BasePart:GetTouchingParts()` should be used. There is a higher
cost to using `Class.BasePart:GetTouchingParts()` since a part is needed
in the `Class.WorldRoot` and the function takes more time to run.
code_samples:
parameters:
- name: region
type: Region3
default:
summary: |
The `Datatype.Region3` to be checked.
- name: ignoreDescendentsInstance
type: Instance
default: nil
summary: |
An `Class.Instance` to be ignored.
returns:
- type: bool
summary: |
True if the `Datatype.Region3` is empty.
tags:
- Deprecated
deprecation_message: |
This function has been deprecated. Use
`Class.WorldRoot:GetPartBoundsInBox()` along with `Datatype.OverlapParams`
for new work.
security: None
thread_safety: Unsafe
capabilities: []
writeCapabilities: []
- name: WorldRoot:IsRegion3EmptyWithIgnoreList
summary: |
Returns a boolean indicating whether there are no
`Class.BasePart|BaseParts` within the given `Datatype.Region3`, ignoring
any `Class.BasePart|BaseParts` that are descendants of the objects within
the given ignore list.
description: |
Returns a boolean indicating whether there are no
`Class.BasePart|BaseParts` within the given `Datatype.Region3`, ignoring
any `Class.BasePart|BaseParts` that are descendants of the objects within
the given ignore list. If a `nil` value is given in the ignore list,
instances after this value will not be ignored.
This function only returns if a region is empty or not. Developers looking
to find specific `Class.BasePart|BaseParts` in a region should use
`Class.WorldRoot:FindPartsInRegion3WithIgnoreList()`.
This function is a variant of `Class.WorldRoot:IsRegion3Empty()` with the
addition of an ignore list. In cases where an inclusion list is required
instead, developers should check to see if any parts are returned by
`Class.WorldRoot:FindPartsinRegion3WithWhitelist()`.
code_samples:
parameters:
- name: region
type: Region3
default:
summary: |
The `Datatype.Region3` to be checked.
- name: ignoreDescendentsTable
type: Instances
default:
summary: |
An array of objects to be ignored.
returns:
- type: bool
summary: |
True if the `Datatype.Region3` is empty.
tags:
- Deprecated
deprecation_message: |
This function has been deprecated. Use
`Class.WorldRoot:GetPartBoundsInBox()` along with `Datatype.OverlapParams`
for new work.
security: None
thread_safety: Unsafe
capabilities: []
writeCapabilities: []
- name: WorldRoot:Raycast
summary: |
Casts a ray using an origin, direction, and optional
`Datatype.RaycastParams`, then returns a `Datatype.RaycastResult` if an
eligible object or terrain intersects the ray.
description: |
Casts a ray using an origin, direction, and optional
`Datatype.RaycastParams`. If it finds an eligible `Class.BasePart` or
`Class.Terrain` cell, a `Datatype.RaycastResult` is returned containing
the results of the operation. If no `Datatype.RaycastParams` object is
provided, the defaults are used (all parts are considered and
`Class.Terrain` water is not ignored).
Note that the length (magnitude) of the directional vector is important,
as objects/terrain further away than its length will not be tested. If
you're using a `Datatype.CFrame` to help create the ray components,
consider using `Datatype.CFrame.LookVector` as the directional vector and
multiply it by the desired length as shown in the example below. The
maximum length of the direction vector is 15,000 studs.
This method does **not** use a `Datatype.Ray` object, but its origin and
direction components can be borrowed from `Datatype.Ray.Origin` and
`Datatype.Ray.Direction`.
code_samples:
- worldroot---raycast
parameters:
- name: origin
type: Vector3
default:
summary: |
The origin point of the ray.
- name: direction
type: Vector3
default:
summary: |
The directional vector of the ray. Note that the length of this vector
matters, as parts/terrain further away than its length will not be
tested.
- name: raycastParams
type: RaycastParams
default: RaycastParams{IgnoreWater=false, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}
summary: |
An object used to specify hit eligibility in the raycast operation. If
not provided, default values are used where all parts are considered
and `Class.Terrain` water is not ignored.
returns:
- type: RaycastResult?
summary: |
Contains the results of a raycast operation, or `nil` if no eligible
`Class.BasePart` or `Class.Terrain` cell was hit.
tags: []
deprecation_message: ''
security: None
thread_safety: Safe
capabilities: []
writeCapabilities: []
- name: WorldRoot:Shapecast
summary: ''
description: ''
code_samples: []
parameters:
- name: part
type: BasePart
default:
summary: ''
- name: direction
type: Vector3
default:
summary: ''
- name: params
type: RaycastParams
default: RaycastParams{IgnoreWater=false, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}
summary: ''
returns:
- type: RaycastResult?
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities: []
writeCapabilities: []
- name: WorldRoot:Spherecast
summary: |
Casts a spherical shape in a given direction and returns a
`Datatype.RaycastResult` if the shape hits a `Class.BasePart` or
`Class.Terrain` cell.
description: |
Casts a spherical shape in a given direction and returns the first
collision with a `Class.BasePart` or `Class.Terrain` cell. This is
analogous to how `Class.WorldRoot:Raycast()` casts a linear ray in a
direction to find a collision, but it uses a 3D shape instead of a ray.
Unlike `Class.WorldRoot:GetPartsInPart()`, this method does not detect
`Class.BasePart|BaseParts` that **initially** intersect the shape.
If a hit is detected, a `Datatype.RaycastResult` is returned containing
the hit information. The `Datatype.RaycastResult.Distance|Distance`
property represents the distance the shape has to travel to find a hit,
and the `Datatype.RaycastResult.Position|Position` property represents the
intersection point that causes the hit.
This method throws an error if it is passed invalid radius or direction
inputs.
code_samples:
- worldroot---spherecast
parameters:
- name: position
type: Vector3
default:
summary: |
The initial position of the cast spherical shape.
- name: radius
type: float
default:
summary: |
The radius of the cast spherical shape in studs. The maximum radius is
256 studs.
- name: direction
type: Vector3
default:
summary: |
Direction of the shapecast, with the magnitude representing the
maximum distance the shape can travel. The maximum distance is 1024
studs.
- name: params
type: RaycastParams
default: RaycastParams{IgnoreWater=false, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}
summary: ''
returns:
- type: RaycastResult?
summary: |
Contains the result of the shapecast operation, or `nil` if no
eligible `Class.BasePart` or `Class.Terrain` cell was hit.
tags: []
deprecation_message: ''
security: None
thread_safety: Safe
capabilities: []
writeCapabilities: []
- name: WorldRoot:StepPhysics
summary: |
Advances the simulation for parts in the world forward based on a
specified time increment and an optional set of
`Class.BasePart|BaseParts`.
description: |
Advances the simulation for parts in the world forward based on a
specified time increment and an optional set of `Class.BasePart`. When a
set of parts is specified, only these parts will be simulated and all
other parts in the world will be treated as anchored. When this argument
is left out, all parts in the world will be included in the simulation.
The specified time increment can be any positive number, with larger
values increasing the runtime of the function. Depending on the value of
the time increment, the physics system may subdivide it into multiple
individual steps to maintain the accuracy and stability of the simulation.
Even if the function performs multiple substeps, the results of the
simulation will only be seen once the function completes. To visualize the
individual steps of a simulation, the function can be called once per
RenderStep via the `Class.RunService.RenderStepped` event.
code_samples:
- worldroot---stepphysics
parameters:
- name: dt
type: float
default:
summary: |
The amount of time that will be simulated. This argument must be a
positive number. Larger values will increase the runtime of this
function.