Skip to content

Commit

Permalink
Merge pull request Polytoria#78 from InsertSoda/ALotOfInputStuff
Browse files Browse the repository at this point in the history
New Environment and Input methods and properties
  • Loading branch information
willemsteller authored May 15, 2024
2 parents 27d451c + 6023a01 commit 5e8298f
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 2 deletions.
30 changes: 30 additions & 0 deletions docs/objects/game/Environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,36 @@ game["Environment"]:CreateExplosion(Vector3.New(0, 0, 0), 30, 5000, false, nil,
!!! note "Callback gets called for each part within explosion radius."
</div>

### OverlapBox(position;Vector3,size;Vector3,rotation;Vector3,ignoreList;array=Instance[]):Instance[] { method }

Returns a list of instances intersecting with the sphere in the given position and radius.

A demo of this method is available [here](https://polytoria.com/places/9269).

**Example**

```lua
local intersections = game["Environment"]:OverlapBox(Vector3.New(0,0,0), Vector3.New(2,2,3), Vector3.New(0,0,0))

for i,v in ipairs(intersections) do
print(v.Name .." is intersecting the box!")
end
```

### OverlapSphere(position;Vector3,radius;float,ignoreList;array=Instance[]):Instance[] { method }

Returns a list of instances intersecting with the sphere in the given position and radius.

**Example**

```lua
local intersections = game["Environment"]:OverlapSphere(Vector3.New(100,0,45), 25)

for i,v in ipairs(intersections) do
print(v.Name .." is intersecting the sphere!")
end
```

### Raycast(origin;Vector3,direction;Vector3,maxDistance;float=infinite,ignoreList;array=Instance[]):RayResult { method }

Casts a ray from origin with a specified direction and returns a RayResult for the first hit object.
Expand Down
56 changes: 54 additions & 2 deletions docs/objects/static-classes/Input.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,55 @@ end)

</div>

### ScreenPointToRay(Vector3;pos, List ignoreList = null):RayResult { method }
### GetAxis(axisName;string):float { method }

Returns the value of the specified axis.

### GetAxisRaw(axisName;string):float { method }

Returns the value of the specified axis without smoothing filtering.

### GetButton(buttonName;string):bool { method }

Returns `true` if the specified button is being held down.

### GetButtonDown(buttonName;string):bool { method }

Returns `true` during the frame in which the specified button was pressed.

### GetButtonUp(buttonName;string):bool { method }

Returns `true` during the frame in which the specified button was released.

### GetKey(keyName;string):bool { method }

Returns `true` if the specified key is being held down.

### GetKeyDown(keyName;string):bool { method }

Returns `true` during the frame in which the specified key was pressed.

### GetKeyUp(keyName;string):bool { method }

Returns `true` during the frame in which the specified key was released.

### GetMouseButton(mouseButton;int):bool { method }

Returns `true` if the specified mouse button is being held down.

### GetMouseButtonDown(mouseButton;int):bool { method }

Returns `true` during the frame in which the specified mouse button was pressed.

### GetMouseButtonUp(mouseButton;int):bool { method }

Returns `true` during the frame in which the specified mouse button was released.

### ScreenPointToRay(position;Vector3, List ignoreList = null):RayResult { method }

Cast a ray from the camera at screen point into the game world

### ViewportPointToRay(Vector3;pos, List ignoreList = null):RayResult { method }
### ViewportPointToRay(position;Vector3, List ignoreList = null):RayResult { method }

Cast a ray from the camera at the specified ViewportPoint (Vector3 with components with values in range of 0 - 1 describing how far a point is to to right and to the top of the screen) into the game world

Expand Down Expand Up @@ -93,6 +137,14 @@ Transforms `worldPosition` from world space into viewport space.

## Properties

### AnyKey:bool { property }

Returns `true` if any key is being pressed.

### AnyKeyDown:bool { property }

Returns `true` if any new key presses happened during the current frame. Held down key presses from previous frames do not count.

### MousePosition:Vector2 { property }

Returns the current mouse position.
Expand Down

0 comments on commit 5e8298f

Please sign in to comment.