Gameplay / PhysicsService
PhysicsService Class
Collision group
Table of contents
Accessors
touchesUseCollisionGroups(): boolean other |
---|
Determine whether models set to non collision in different groups ignore touch events while ignoring collisions |
Methods
addCollisionGroup(name : string ): void other |
---|
Add a new collision group |
boxOverlap(boxPos : Vector , boxExtent : Vector , collisionParams : CollisionQueryParams , renderParams : RenderQueryParams ): GameObject [] other |
Return an array of objects that overlap with the given box body |
boxTraceMulti(start : Vector , end : Vector , halfSize : Vector , orientation : Rotation , collisionParams : CollisionQueryParams , renderParams : RenderQueryParams ): HitResult [] other |
Scan a box along a given route and return all hits encountered, including the first interception hit. |
boxTraceSingle(start : Vector , end : Vector , halfSize : Vector , orientation : Rotation , collisionParams : CollisionQueryParams , renderParams : RenderQueryParams ): HitResult other |
Scan a box along a given line and return the first obstruction hit encountered. |
capsuleOverlap(capsulePos : Vector , radius : number , halfHeight : number , collisionParams : CollisionQueryParams , renderParams : RenderQueryParams ): GameObject [] other |
Return an array of objects that overlap with the given capsule body |
capsuleTraceMulti(start : Vector , end : Vector , radius : number , halfHeight : number , collisionParams : CollisionQueryParams , renderParams : RenderQueryParams ): HitResult [] other |
Scan a capsule along a given route and return all hits encountered, including the first interception hit. |
capsuleTraceSingle(start : Vector , end : Vector , radius : number , halfHeight : number , collisionParams : CollisionQueryParams , renderParams : RenderQueryParams ): HitResult other |
Scan a capsule along a given line and return the first obstruction hit encountered. |
deleteCollisionGroup(name : string ): void other |
Delete existing collision groups |
getAvailableCollisionGroupsCount(): number other |
Get the current number of available collision groups |
getCollisionBetweenGroups(group1 : string , group2 : string ): boolean other |
Obtain the collision relationship between two collision groups (whether collision can occur) |
getValidCollisionGroups(): string [] other |
Retrieve the list of currently added collision group names |
isCollisionGroupValid(name : string ): boolean other |
Whether the detect collision group is valid (added) |
lineTraceMulti(start : Vector , end : Vector , collisionParams : CollisionQueryParams , renderParams : RenderQueryParams ): HitResult [] other |
Perform collision tracking along the given line and return all hits encountered until and including the first blocking hit. |
lineTraceSingle(start : Vector , end : Vector , collisionParams : CollisionQueryParams , renderParams : RenderQueryParams ): HitResult other |
Perform collision tracking along the given line and return the first obstacle hit encountered. |
renameCollisionGroup(previousName : string , newName : string ): void other |
Rename a collision group |
setCollisionBetweenGroups(group1 : string , group2 : string , collidable : boolean ): void other |
Set the collision relationship between two collision groups (whether collisions can occur) |
sphereOverlap(spherePos : Vector , sphereRadius : number , collisionParams : CollisionQueryParams , renderParams : RenderQueryParams ): GameObject [] other |
Return an array of objects that overlap with the given sphere |
sphereTraceMulti(start : Vector , end : Vector , radius : number , collisionParams : CollisionQueryParams , renderParams : RenderQueryParams ): HitResult [] other |
Scan a sphere along a given straight line and return all hits, including the first interception hit. |
sphereTraceSingle(start : Vector , end : Vector , radius : number , collisionParams : CollisionQueryParams , renderParams : RenderQueryParams ): HitResult other |
Scan a sphere along a given line and return the first obstruction hit encountered. |
Accessors
touchesUseCollisionGroups
• | • | ||||
---|---|---|---|---|---|
Determine whether models set to non collision in different groups ignore touch events while ignoring collisions Returns
| Determine whether models set to non collision in different groups ignore touch events while ignoring collisions Usage example: Create a script named TouchesUseCollisionGroups in the scene, drag it into the scene, and copy the following code into the script. After press 1 and 2, the server will call the onTouch function and output the corresponding LOG. ts
Parameters
|
Methods
addCollisionGroup
• Static
addCollisionGroup(name
): void
other
Add a new collision group
Parameters
name string | Usage: collision group name range: unlimited |
---|
Usage example: create a script named CollisionGroup in the scene, drag it into the scene, and copy the following code into the script. Press 1 to see the output "GroupA, GroupB, GroupC" in the editor window client
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
PhysicsService.addCollisionGroup("GroupC");
console.log(PhysicsService.getValidCollisionGroups());
})
}
}
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
PhysicsService.addCollisionGroup("GroupC");
console.log(PhysicsService.getValidCollisionGroups());
})
}
}
boxOverlap
• Static
boxOverlap(boxPos
, boxExtent
, collisionParams
, renderParams
): GameObject
[] other
Return an array of objects that overlap with the given box body
Parameters
boxPos Vector | Usage: detect position |
---|---|
boxExtent Vector | Usage: Box size |
collisionParams CollisionQueryParams | Usage: Collision query rendering parameters |
renderParams RenderQueryParams | Usage: Spatial query rendering parameters |
Returns
GameObject [] | GameObject array |
---|
Usage example: The following example shows the basic process of using rectangle range detect
const result = PhysicsService.boxOverlap(new mw.Vector(0,0,0), new Vector(30, 30, 30), {}, {});
for (const item of result) {
// item: Test results.
}
const result = PhysicsService.boxOverlap(new mw.Vector(0,0,0), new Vector(30, 30, 30), {}, {});
for (const item of result) {
// item: Test results.
}
boxTraceMulti
• Static
boxTraceMulti(start
, end
, halfSize
, orientation
, collisionParams
, renderParams
): HitResult
[] other
Scan a box along a given route and return all hits encountered, including the first interception hit.
Parameters
start Vector | starting point |
---|---|
end Vector | Usage: Termination Point |
halfSize Vector | Box size |
orientation Rotation | Rotation size |
collisionParams CollisionQueryParams | Usage: Spatial query collision parameters |
renderParams RenderQueryParams | Usage: Spatial query rendering parameters |
Returns
HitResult [] | HitResult array |
---|
Usage example: The following example shows the basic process of using rectangle range detect
const result = PhysicsService.boxTraceMulti(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), new Vector(30, 30, 30), new Rotation(45, 45, 45), {}, {});
for (const item of result) {
// item: Test results.
}
const result = PhysicsService.boxTraceMulti(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), new Vector(30, 30, 30), new Rotation(45, 45, 45), {}, {});
for (const item of result) {
// item: Test results.
}
boxTraceSingle
• Static
boxTraceSingle(start
, end
, halfSize
, orientation
, collisionParams
, renderParams
): HitResult
other
Scan a box along a given line and return the first obstruction hit encountered.
Parameters
start Vector | starting point |
---|---|
end Vector | Usage: Termination Point |
halfSize Vector | Box size |
orientation Rotation | Rotation size |
collisionParams CollisionQueryParams | Usage: Spatial query collision parameters |
renderParams RenderQueryParams | Usage: Spatial query rendering parameters |
Returns
HitResult | HitResult |
---|
Usage example: The following example shows the basic process of using rectangle range detect
const result = PhysicsService.boxTraceSingle(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), new Vector(30, 30, 30), new Rotation(45, 45, 45), {}, {});
const result = PhysicsService.boxTraceSingle(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), new Vector(30, 30, 30), new Rotation(45, 45, 45), {}, {});
capsuleOverlap
• Static
capsuleOverlap(capsulePos
, radius
, halfHeight
, collisionParams
, renderParams
): GameObject
[] other
Return an array of objects that overlap with the given capsule body
Parameters
capsulePos Vector | Usage: detect position |
---|---|
radius number | Capsule body radius |
halfHeight number | Usage: Half height of capsule body |
collisionParams CollisionQueryParams | Usage: Collision query rendering parameters |
renderParams RenderQueryParams | Usage: Spatial query rendering parameters |
Returns
GameObject [] | GameObject array |
---|
Usage example: The following example shows the basic process of using rectangle range detect
const result = PhysicsService.capsuleOverlap(new mw.Vector(0,0,0), 30, 80, {}, {});
for (const item of result) {
// item: Test results.
}
const result = PhysicsService.capsuleOverlap(new mw.Vector(0,0,0), 30, 80, {}, {});
for (const item of result) {
// item: Test results.
}
capsuleTraceMulti
• Static
capsuleTraceMulti(start
, end
, radius
, halfHeight
, collisionParams
, renderParams
): HitResult
[] other
Scan a capsule along a given route and return all hits encountered, including the first interception hit.
Parameters
start Vector | starting point |
---|---|
end Vector | Usage: Termination Point |
radius number | Capsule body radius |
halfHeight number | Half height of capsule body |
collisionParams CollisionQueryParams | Usage: Spatial query collision parameters |
renderParams RenderQueryParams | Usage: Spatial query rendering parameters |
Returns
HitResult [] | HitResult array |
---|
Usage example: The following example shows the basic process of using rectangle range detect
const result = PhysicsService.capsuleTraceMulti(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), 30, 80, {}, {});
for (const item of result) {
// item: Test results.
}
const result = PhysicsService.capsuleTraceMulti(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), 30, 80, {}, {});
for (const item of result) {
// item: Test results.
}
capsuleTraceSingle
• Static
capsuleTraceSingle(start
, end
, radius
, halfHeight
, collisionParams
, renderParams
): HitResult
other
Scan a capsule along a given line and return the first obstruction hit encountered.
Parameters
start Vector | starting point |
---|---|
end Vector | Usage: Termination Point |
radius number | Capsule body radius |
halfHeight number | Half height of capsule body |
collisionParams CollisionQueryParams | Usage: Spatial query collision parameters |
renderParams RenderQueryParams | Usage: Spatial query rendering parameters |
Returns
HitResult | HitResult |
---|
Usage example: The following example shows the basic process of using rectangle range detect
const result = PhysicsService.capsuleTraceSingle(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), 30, 80, {}, {});
const result = PhysicsService.capsuleTraceSingle(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), 30, 80, {}, {});
deleteCollisionGroup
• Static
deleteCollisionGroup(name
): void
other
Delete existing collision groups
Parameters
name string | Usage: collision group name range: unlimited |
---|
Usage example: Create a script called CollisionGroup in the scene, drag it into the scene, and copy the following code into the script. Press 1 to see the output "GroupB" in the editor window client
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
PhysicsService.deleteCollisionGroup("GroupA");
console.log(PhysicsService.getValidCollisionGroups());
})
}
protected onUpdate(dt: number): void {
}
// Call this function after the last frame is executed when the script is destroyed
protected onDestroy(): void {
}
}
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
PhysicsService.deleteCollisionGroup("GroupA");
console.log(PhysicsService.getValidCollisionGroups());
})
}
protected onUpdate(dt: number): void {
}
// Call this function after the last frame is executed when the script is destroyed
protected onDestroy(): void {
}
}
getAvailableCollisionGroupsCount
• Static
getAvailableCollisionGroupsCount(): number
other
Get the current number of available collision groups
Returns
number | Remaining number of available collision groups |
---|
Usage example: Create a script called CollisionGroup in the scene, drag it into the scene, and copy the following code into the script. After pressing 1, you can see the output "8" in the editor window client
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
console.log(PhysicsService.getAvailableCollisionGroupsCount());
})
}
}
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
console.log(PhysicsService.getAvailableCollisionGroupsCount());
})
}
}
getCollisionBetweenGroups
• Static
getCollisionBetweenGroups(group1
, group2
): boolean
other
Obtain the collision relationship between two collision groups (whether collision can occur)
Parameters
group1 string | Usage: Collision group name 1 range: Unrestricted |
---|---|
group2 string | Usage: collision group name 2 range: unlimited |
Returns
boolean | Collision relationship (whether collision can occur) |
---|
Usage example: Create a script called CollisionGroup in the scene, drag it into the scene, and copy the following code into the script. After pressing 1, you can see the output 'false' in the editor window client
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
console.log(PhysicsService.getCollisionBetweenGroups("GroupA", "GroupB"));
})
}
}
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
console.log(PhysicsService.getCollisionBetweenGroups("GroupA", "GroupB"));
})
}
}
getValidCollisionGroups
• Static
getValidCollisionGroups(): string
[] other
Retrieve the list of currently added collision group names
Returns
string [] | List of currently added collision group names |
---|
Usage example: create a script named CollisionGroup in the scene, drag it into the scene, and copy the following code into the script. Press 1 to see the output "GroupA, GroupB" in the editor window client
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
console.log(PhysicsService.getValidCollisionGroups());
})
}
}
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
console.log(PhysicsService.getValidCollisionGroups());
})
}
}
isCollisionGroupValid
• Static
isCollisionGroupValid(name
): boolean
other
Whether the detect collision group is valid (added)
Parameters
name string | Usage: collision group name range: unlimited |
---|
Returns
boolean | Whether the collision group is valid |
---|
Usage example: create a script named CollisionGroup in the scene, drag it into the scene, and copy the following code into the script. After pressing 1, you can see the output 'false' in the editor window client
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
console.log(PhysicsService.isCollisionGroupValid("GroupC"));
})
}
}
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
console.log(PhysicsService.isCollisionGroupValid("GroupC"));
})
}
}
lineTraceMulti
• Static
lineTraceMulti(start
, end
, collisionParams
, renderParams
): HitResult
[] other
Perform collision tracking along the given line and return all hits encountered until and including the first blocking hit.
Parameters
start Vector | starting point |
---|---|
end Vector | Usage: Termination Point |
collisionParams CollisionQueryParams | Usage: Spatial query collision parameters |
renderParams RenderQueryParams | Usage: Spatial query rendering parameters |
Returns
HitResult [] | HitResult array |
---|
Usage example: The following example shows the basic process of using rectangle range detect
const result = PhysicsService.lineTraceMulti(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), {}, {});
for (const item of result) {
// item: Test results.
}
const result = PhysicsService.lineTraceMulti(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), {}, {});
for (const item of result) {
// item: Test results.
}
lineTraceSingle
• Static
lineTraceSingle(start
, end
, collisionParams
, renderParams
): HitResult
other
Perform collision tracking along the given line and return the first obstacle hit encountered.
Parameters
start Vector | starting point |
---|---|
end Vector | Usage: Termination Point |
collisionParams CollisionQueryParams | Usage: Spatial query collision parameters |
renderParams RenderQueryParams | Usage: Spatial query rendering parameters |
Returns
HitResult | HitResult |
---|
Usage example: The following example shows the basic process of using rectangle range detect
const result = PhysicsService.lineTraceSingle(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), {}, {});
const result = PhysicsService.lineTraceSingle(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), {}, {});
renameCollisionGroup
• Static
renameCollisionGroup(previousName
, newName
): void
other
Rename a collision group
Parameters
previousName string | Usage: collision group name range: unlimited |
---|---|
newName string | Usage: New collision group name range: Unrestricted |
Usage example: create a script named CollisionGroup in the scene, drag it into the scene, and copy the following code into the script. After pressing 1, you can see the output "GroupB, GroupC" in the editor window client
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
PhysicsService.renameCollisionGroup("GroupA","GroupC");
console.log(PhysicsService.getValidCollisionGroups());
})
}
protected onUpdate(dt: number): void {
}
// Call this function after the last frame is executed when the script is destroyed
protected onDestroy(): void {
}
}
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
PhysicsService.renameCollisionGroup("GroupA","GroupC");
console.log(PhysicsService.getValidCollisionGroups());
})
}
protected onUpdate(dt: number): void {
}
// Call this function after the last frame is executed when the script is destroyed
protected onDestroy(): void {
}
}
setCollisionBetweenGroups
• Static
setCollisionBetweenGroups(group1
, group2
, collidable
): void
other
Set the collision relationship between two collision groups (whether collisions can occur)
Parameters
group1 string | Usage: collision group name 1 range: unlimited |
---|---|
group2 string | Usage: Collision group name 2 range: Unrestricted |
collidable boolean | Usage: Can collision occur |
Usage example: Create a script called CollisionGroup in the scene, drag it into the scene, and copy the following code into the script. Press 1 and 2 to see two balls generate in the scene, and push the nearest ball to hit the other. It will be found that Player can collision with the ball, but the two balls can penetrate.
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
this.serverCreateBall(new Vector(300, 0, 0), "GroupA", true);
})
// Create sphere B with normal collision and set the collision group to GroupB
InputUtil.onKeyDown(Keys.Two, ()=>{
this.serverCreateBall(new Vector(600, 0, 0), "GroupB", false);
})
}
@mw.RemoteFunction(mw.Server)
serverCreateBall(pos:Vector, Group:string, bPhysicsSimulate:boolean)
{
GameObject.asyncSpawn("197388", {replicates:true}).then((obj)=>{
let ball = obj as mw.Model;
ball.worldTransform.position = pos;
if (bPhysicsSimulate)
{
ball.physicsEnabled = true;
ball.massEnabled = true;
ball.mass = 50;
}
ball.collisionGroup = Group;
})
}
}
@Component
export default class CollisionGroup extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected onStart(): void {
PhysicsService.addCollisionGroup("GroupA");
PhysicsService.addCollisionGroup("GroupB");
PhysicsService.setCollisionBetweenGroups("GroupA", "GroupB", false);
// Create the sphere A simulating physics and set the collision group as GroupA
InputUtil.onKeyDown(Keys.One, ()=>{
this.serverCreateBall(new Vector(300, 0, 0), "GroupA", true);
})
// Create sphere B with normal collision and set the collision group to GroupB
InputUtil.onKeyDown(Keys.Two, ()=>{
this.serverCreateBall(new Vector(600, 0, 0), "GroupB", false);
})
}
@mw.RemoteFunction(mw.Server)
serverCreateBall(pos:Vector, Group:string, bPhysicsSimulate:boolean)
{
GameObject.asyncSpawn("197388", {replicates:true}).then((obj)=>{
let ball = obj as mw.Model;
ball.worldTransform.position = pos;
if (bPhysicsSimulate)
{
ball.physicsEnabled = true;
ball.massEnabled = true;
ball.mass = 50;
}
ball.collisionGroup = Group;
})
}
}
sphereOverlap
• Static
sphereOverlap(spherePos
, sphereRadius
, collisionParams
, renderParams
): GameObject
[] other
Return an array of objects that overlap with the given sphere
Parameters
spherePos Vector | Usage: detect position |
---|---|
sphereRadius number | Usage: sphere radius |
collisionParams CollisionQueryParams | Usage: Collision query rendering parameters |
renderParams RenderQueryParams | Usage: Spatial query rendering parameters |
Returns
GameObject [] | GameObject array |
---|
Usage example: The following example shows the basic process of using rectangle range detect
const result = PhysicsService.sphereOverlap(new mw.Vector(0,0,0), 30, {}, {});
for (const item of result) {
// item: Test results.
}
const result = PhysicsService.sphereOverlap(new mw.Vector(0,0,0), 30, {}, {});
for (const item of result) {
// item: Test results.
}
sphereTraceMulti
• Static
sphereTraceMulti(start
, end
, radius
, collisionParams
, renderParams
): HitResult
[] other
Scan a sphere along a given straight line and return all hits, including the first interception hit.
Parameters
start Vector | starting point |
---|---|
end Vector | Usage: Termination Point |
radius number | Spherical radius |
collisionParams CollisionQueryParams | Usage: Spatial query collision parameters |
renderParams RenderQueryParams | Usage: Spatial query rendering parameters |
Returns
HitResult [] | HitResult array |
---|
Usage example: The following example shows the basic process of using rectangle range detect
const result = PhysicsService.sphereTraceMulti(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), 30, {}, {});
for (const item of result) {
// item: Test results.
}
const result = PhysicsService.sphereTraceMulti(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), 30, {}, {});
for (const item of result) {
// item: Test results.
}
sphereTraceSingle
• Static
sphereTraceSingle(start
, end
, radius
, collisionParams
, renderParams
): HitResult
other
Scan a sphere along a given line and return the first obstruction hit encountered.
Parameters
start Vector | starting point |
---|---|
end Vector | Usage: Termination Point |
radius number | Spherical radius |
collisionParams CollisionQueryParams | Usage: Spatial query collision parameters |
renderParams RenderQueryParams | Usage: Spatial query rendering parameters |
Returns
HitResult | HitResult |
---|
Usage example: The following example shows the basic process of using rectangle range detect
const result = PhysicsService.sphereTraceSingle(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), 30, {}, {});
const result = PhysicsService.sphereTraceSingle(new mw.Vector(0,0,0), new mw.Vector(1000,0,0), 30, {}, {});