### Function Example in Lua Source: https://etithespir.it/FastCastAPIDocs/custom-classes/function Illustrates the interpretation of Function in Lua. The first type parameter 'boolean' is the return type, and the subsequent 'number, number' are the parameter types. ```lua function MyFunction(a, b) -- a and b are numbers -- ... some code here return true -- or return false end ``` -------------------------------- ### Function Example in Lua Source: https://etithespir.it/FastCastAPIDocs/custom-classes/function Demonstrates the interpretation of Function in Lua. The single type parameter 'number' represents the return type, indicating a function that returns a number and takes no parameters. ```lua function MyFunction() -- ... some code here return 0 --or any number end ``` -------------------------------- ### Luau Nullable Type Function Call Examples Source: https://etithespir.it/FastCastAPIDocs/custom-classes/nullable Illustrates valid and invalid function calls for a Luau function with a required and a nullable parameter. Passing `nil` to a nullable parameter is allowed, while passing `nil` to a required parameter will result in an error. Omitting a nullable parameter is treated as `nil`. ```luau MyFunction(123, nil) -- Valid: nullableNumber is nil MyFunction(123) -- Valid: nullableNumber is omitted, treated as nil -- MyFunction(nil, nil) -- Error: requiredNumber cannot be nil ``` -------------------------------- ### PartCache Integration for Cosmetic Bullets Source: https://etithespir.it/FastCastAPIDocs/fastcast-objects/fcbehavior Utilize PartCache via CosmeticBulletProvider for efficient management of cosmetic bullet instances, especially in performance-critical scenarios. ```APIDOC ## PartCache Integration (CosmeticBulletProvider) ### Description Provides an alternative to `CosmeticBulletTemplate` by using a `PartCache` instance. This is crucial for performance in games with numerous projectiles, as it optimizes the acquisition of bullet instances. ### Method N/A (Configuration setting) ### Endpoint N/A (Configuration setting) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **PartCache** (Instance) - Required - The PartCache instance to be used by FastCast. - **CosmeticBulletProvider** (Instance) - Required - The provider that integrates PartCache with FastCast. ### Request Example ```json { "PartCache": "Instance", "CosmeticBulletProvider": "Instance" } ``` ### Response #### Success Response (200) N/A (Configuration setting) #### Response Example N/A ``` -------------------------------- ### RBXLuaScriptSignal API Source: https://etithespir.it/FastCastAPIDocs/custom-classes/signal Methods for creating and managing custom events. ```APIDOC ## RBXLuaScriptSignal An unofficial wrapped variant of an RBXScriptSignal featuring versatile API used to create custom events. This object is created via the Signal module included in FastCast through the `Signal.new()` function. ### Methods #### RBXLuaScriptSignalConnection Connect(function func) Runs `func` when the event fires, passing in all of the arguments specified in Fire(...) to this function. - **func** (function) - The function to be called when the event fires. - **Returns**: RBXLuaScriptSignalConnection - An object representing the connection. #### Tuple Wait() Delays the current thread until the event has fired, returning all of the arguments specified when the event was fired. - **Returns**: Tuple - Arguments passed when the event was fired. #### void DisconnectAll() Forces all connections made to this RBXLuaScriptSignal to disconnect. This should be called if your custom object is destroyed, otherwise you may cause memory leaks. #### void Fire(Tuple args...) Fires the event with the specified arguments. - **args** (Tuple) - Arguments to be passed to connected functions. ``` -------------------------------- ### RBXLuaScriptSignalConnection API Source: https://etithespir.it/FastCastAPIDocs/custom-classes/signal Methods for managing individual event connections. ```APIDOC ## RBXLuaScriptSignalConnection This is a connection object returned by the Connect method of RBXLuaScriptSignal:Connect(). ### Methods #### void Disconnect() Causes this event to disconnect from its parent RBXLuaScriptSignal (it will never be run when the event is fired after disconnection). ``` -------------------------------- ### Cosmetic Bullet Template Configuration Source: https://etithespir.it/FastCastAPIDocs/fastcast-objects/fcbehavior Configure the visual template for cosmetic bullets. This can be overridden by CosmeticBulletProvider for performance. ```APIDOC ## CosmeticBulletTemplate Configuration ### Description Defines a template for cosmetic bullets. When the Fire method is called, this template is duplicated and parented to `CosmeticBulletContainer`, then updated via the `LengthChanged` event. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **CosmeticBulletTemplate** (Instance) - Optional - A template object for cosmetic bullets. - **CosmeticBulletContainer** (Instance) - Optional - A container object for cosmetic bullets. If provided, bullets are parented here. If `CosmeticBulletProvider` is defined, this is ignored. - **CosmeticBulletProvider** (Instance) - Optional - An alternative to `CosmeticBulletTemplate` that uses `PartCache` for bullet instances. Recommended for performance. ### Request Example ```json { "CosmeticBulletTemplate": "Instance", "CosmeticBulletContainer": "Instance", "CosmeticBulletProvider": "Instance" } ``` ### Response #### Success Response (200) This configuration does not directly return data but affects the behavior of FastCast. #### Response Example N/A ``` -------------------------------- ### CastRayInfo Properties Source: https://etithespir.it/FastCastAPIDocs/fastcast-objects/castrayinfo This section details the properties of the CastRayInfo object. ```APIDOC ## CastRayInfo A CastRayInfo stores information about how an ActiveCast should fire its rays. It is safe to alter this in real-time. ### Properties #### RaycastParams RaycastParams **Description**: The RaycastParams used in all raycasts from this ActiveCast. This can be freely edited. When the ActiveCast is instantiated, the input parameters are cloned, and this property is set to the clone instance. Access this and change its properties instead of changing it to a new RaycastParams instance. #### WorldRoot WorldRoot **Description**: The WorldRoot that this ActiveCast should simulate in. By default, it is equal to whatever its parent Caster is set to, but can be changed at any time. #### number MaxDistance **Description**: The maximum distance that the ray can travel. By default, it is the magnitude of the parent Caster's `directionWithMagnitude` parameter when the Fire method is called. #### Instance CosmeticBulletObject **Description**: A reference to the input cosmetic bullet from the parent Caster's Fire method. See Caster for more information. #### function CanPierceCallback **Description**: A reference to the input pierce function from the parent Caster's Fire method. See Caster for more information. ``` -------------------------------- ### AutoIgnoreContainer Configuration Source: https://etithespir.it/FastCastAPIDocs/fastcast-objects/fcbehavior Control whether the CosmeticBulletContainer is automatically added to the blacklist of RaycastParams when using a blacklist. ```APIDOC ## AutoIgnoreContainer Configuration ### Description If set to true, and `RaycastParams` is configured with a Blacklist, the `CosmeticBulletContainer` will be automatically added to this blacklist when the Fire method is invoked. This setting does not apply if `RaycastParams` uses a Whitelist. ### Method N/A (Configuration setting) ### Endpoint N/A (Configuration setting) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **AutoIgnoreContainer** (boolean) - Optional - Defaults to `true`. If `true`, the `CosmeticBulletContainer` is added to the `RaycastParams` blacklist. ### Request Example ```json { "AutoIgnoreContainer": true } ``` ### Response #### Success Response (200) N/A (Configuration setting) #### Response Example N/A ``` -------------------------------- ### FastCast Lua: Implement CanPierceFunction for Projectile Piercing Source: https://etithespir.it/FastCastAPIDocs/fastcast-objects/fcbehavior Defines a Lua function that FastCast calls when a projectile hits an object. This function determines if the projectile should pierce the object (continue simulation) or stop. It receives the active cast, raycast result, and projectile velocity. Ensure the function executes within a single tick to avoid errors. The raycast result is guaranteed to be non-nil. ```lua function CanRayPierce(cast, result, segmentVelocity) -- Let's pretend my projectile is a laser. if result.Instance.Transparency >= 0.5 then -- This part is at least 50% transparent. -- My laser can pass through these parts. return true end -- It's less than 50% transparent. My laser can not go through these parts. return false end ``` -------------------------------- ### Caster: Fire() Method for Projectile Simulation Source: https://etithespir.it/FastCastAPIDocs/fastcast-objects/caster The Fire method is used to launch a ray (ActiveCast) from the Caster. It takes origin, direction, and velocity as primary arguments, with an optional dataPacket for custom behavior. The velocity can be a Vector3 or a number representing speed. This method initiates the projectile simulation. ```lua local caster = Caster.new() local origin = Vector3.new(0, 5, 0) local direction = Vector3.new(0, 0, -1) local velocity = 100 -- Speed in studs/sec local dataPacket = FastCastBehavior.new() caster:Fire(origin, direction, velocity, dataPacket) ``` -------------------------------- ### CanPierceFunction for Raycast Piercing Logic Source: https://etithespir.it/FastCastAPIDocs/fastcast-objects/fcbehavior Implement a custom function to determine if a projectile should pierce through an object, allowing for complex collision behaviors. ```APIDOC ## CanPierceFunction for Raycast Piercing Logic ### Description Defines a callback function executed when a raycast hits an object. This function determines whether the projectile should pierce the object (returning `true`) or terminate its trajectory (returning `false`). Ensure this function is highly optimized for performance, as FastCast execution halts until it returns. ### Method N/A (Function assignment) ### Endpoint N/A (Function assignment) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **CanPierceFunction** (Func) - Optional - A function that returns `true` to allow piercing or `false` to stop. - Parameter 1: `ActiveCast` (object) - A reference to the `ActiveCast` that invoked the function. - Parameter 2: `RaycastResult` (object) - The result of the raycast. - Parameter 3: `Vector3` - The velocity of the ray at the moment of impact. ### Request Example ```javascript function CanRayPierce(cast, result, segmentVelocity) { // Example: Pierce parts with transparency >= 0.5 if (result.Instance.Transparency >= 0.5) { return true; // Allow piercing } return false; // Terminate trajectory } -- Assigning the function (implementation specific to FastCast API) FastCast.CanPierceFunction = CanRayPierce; ``` ### Response #### Success Response (200) N/A (Function assignment) #### Response Example N/A ``` -------------------------------- ### Caster Event: RayHit for Projectile Impact Detection Source: https://etithespir.it/FastCastAPIDocs/fastcast-objects/caster The RayHit event is triggered when a ray fired by the Caster collides with an object. It provides the ActiveCast, the RaycastResult detailing the hit, the segment velocity at impact, and the cosmetic bullet object. This event should handle the consequences of a hit, such as damage or effects. ```lua caster.RayHit:Connect(function(casterThatFired, result, segmentVelocity, cosmeticBulletObject) print("Ray hit:", result.Instance.Name) -- Apply damage or effects here -- Do NOT delete cosmeticBulletObject here end) ``` -------------------------------- ### Caster Event: CastTerminating for Cleanup Source: https://etithespir.it/FastCastAPIDocs/fastcast-objects/caster The CastTerminating event fires just before an ActiveCast's data is disposed of, typically after RayHit or when the cast reaches its maximum range. It's the recommended place to clean up resources like cosmetic bullet objects, ensuring they are removed after the cast has finished its lifecycle. ```lua caster.CastTerminating:Connect(function(casterThatFired) -- Clean up any associated objects, like the cosmetic bullet if cosmeticBulletObject and cosmeticBulletObject.Parent then cosmeticBulletObject:Destroy() end end) ``` -------------------------------- ### Luau Nullable Type Declaration Source: https://etithespir.it/FastCastAPIDocs/custom-classes/nullable Demonstrates the declaration of a function in Luau with a nullable type parameter. Nullable types are defined by appending a `?` after the type name, indicating that the parameter can accept `nil` values. This is specific to Luau's strong typing and differs from standard Lua. ```luau function MyFunction(requiredNumber: number, nullableNumber: number?) : void -- Function implementation here end ``` -------------------------------- ### Caster Event: RayPierced for Projectile Penetration Source: https://etithespir.it/FastCastAPIDocs/fastcast-objects/caster Similar to RayHit, the RayPierced event fires when a ray penetrates an object. It provides the same parameters: ActiveCast, RaycastResult, segmentVelocity, and cosmeticBulletObject. This event is only triggered if the Caster's canPierceFunction is defined and allows penetration. ```lua caster.RayPierced:Connect(function(casterThatFired, result, segmentVelocity, cosmeticBulletObject) print("Ray pierced:", result.Instance.Name) -- Handle piercing effects or logic here end) ``` -------------------------------- ### Caster Event: LengthChanged for Real-time Ray Updates Source: https://etithespir.it/FastCastAPIDocs/fastcast-objects/caster The LengthChanged event fires whenever a ray fired by the Caster updates its position. It provides details about the ray's previous position, direction, displacement, segment velocity, and any associated cosmetic bullet object. This is useful for visual effects and real-time trajectory updates. ```lua caster.LengthChanged:Connect(function(casterThatFired, lastPoint, rayDir, displacement, segmentVelocity, cosmeticBulletObject) print("Ray moved by:", displacement) -- Update visual representation of the projectile here end) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.