Hi everyone! I'm new here to both Core Games and the forums. I wonder if you can help with the following script (as the API documentation is rather vague around the Camera type).
The current script below references the player that owns this script and the related equipment. Currently, it uses the Player transform to get the facing direction and applies the velocity from the facing direction. It works perfectly as intended.
However, obviously the player transform direction doesn't account for Y axis aiming (which is fine). So, instead of using the direction of the player, I would prefer to use the direction of the player's camera. Therefore, if the user aims upward or downward by moving the camera, the 'Facing Vector' would change accordingly.
Therefore, does anyone know how (or if we can) reference a particular players' camera, and if the 'GetWorldTransform()' function would work?
Thanks in advance
"On_Throw" Script :
local propBall = script:GetCustomProperty("Ball"):WaitForObject() local propPhysicsBall = script:GetCustomProperty("PhysicsBall"):WaitForObject() local propPickupTrigger = script:GetCustomProperty("PickupTrigger"):WaitForObject() local propVelocity = propPhysicsBall:GetCustomProperty("Velocity") local ANG_VELOCITY = propPhysicsBall:GetCustomProperty("AngVelocity") local ability = script.parent function OnExecute(ability) local Equipment = script:FindAncestorByType("Equipment") local EquipmentPos = Equipment:GetWorldPosition() local PlayerHeld = Equipment.owner local PlayerHeldTransform = PlayerHeld:GetWorldTransform() local PlayerFacingVector = PlayerHeldTransform:GetForwardVector() propPhysicsBall.isEnabled = true propPhysicsBall:SetWorldPosition(propBall:GetWorldPosition()) propBall.visibility = Visibility.FORCE_OFF Equipment:Unequip() propPickupTrigger.collision = Collision.FORCE_ON propPhysicsBall:SetVelocity(PlayerFacingVector * propVelocity) propPhysicsBall:SetAngularVelocity(Vector3.UP * ANG_VELOCITY) Task.Wait(2) -- Cut the velocity (and angular velocity) down to 25% propPhysicsBall:SetVelocity(propPhysicsBall:GetVelocity() * 0.25) propPhysicsBall:SetAngularVelocity(propPhysicsBall:GetAngularVelocity() * 0.25) end ability.executeEvent:Connect(OnExecute)