private void ProcessFloorHit() { // On the ground LandingTimeDelta = 0; // Handle buffered jumps if (JumpBuffered()) { // Buffer a jump willJump = true; } MovingGeneric moving_platform = lastHit.gameObject.GetComponent <MovingGeneric>(); if (moving_platform != null) { if (transform.parent != moving_platform.transform) { transform.parent = moving_platform.transform; // Keep custom velocity globally accurate current_velocity -= moving_platform.velocity; } lastMovingPlatform = moving_platform; MovingPlatformTimeDelta = 0; } PreviousWallNormal = Vector3.zero; PreviousWallJumpNormal = Vector3.zero; PreviousWallJumpPos = Vector3.positiveInfinity; }
protected override void Awake() { base.Awake(); IGNORE_RAYCAST_LAYER = LayerMask.NameToLayer("Ignore Raycast"); moving_object = GetComponent <MovingGeneric>(); rb_collider = GetComponent <Collider>(); }
private void rpc_PickupOnServer(uint grabber_netId, int grabber_moId, Vector3 grab_offset) { MovingGeneric target = MovingGeneric.GetMovingObjectAt(grabber_netId, grabber_moId); if (target == null) { return; } bool success = Pickup(target.gameObject, grab_offset, true); if (success) { grabberId = ExecutingRpcSender; } InvokeClientRpcOnClient(rpc_PickupCallback, ExecutingRpcSender, success); }
private void HandleMovingCollisions() { if (!InMovingCollision() && !OnMovingPlatform()) { moving_frame_velocity = Vector3.zero; if (transform.parent != null) { transform.parent = null; // Inherit velocity from previous platform if (lastMovingPlatform != null) { // Keep custom velocity globally accurate current_velocity += lastMovingPlatform.velocity; } } lastMovingPlatform = null; } else if (InMovingCollision()) { moving_frame_velocity = lastMovingPlatform.velocity; } }
public static int GetMovingObjectIndex(MovingGeneric moving_object) { return(MovingObjectDict[moving_object.NetworkId].IndexOf(moving_object)); }
protected override void Awake() { base.Awake(); moving_object = GetComponent <MovingGeneric>(); rb_collider = GetComponent <Collider>(); }
private void ProcessTriggers() { if (lastTrigger == null) { return; } MovingGeneric moving_obj = lastTrigger.GetComponent <MovingCollider>(); if (moving_obj != null) { if (transform.parent != moving_obj.transform) { transform.parent = moving_obj.transform; // Keep custom velocity globally accurate current_velocity -= moving_obj.velocity; } lastMovingPlatform = moving_obj; MovingColliderTimeDelta = 0; } if (!OnGround()) { RaycastHit hit; Boolean hit_wall = false; if (IsWallRunning()) { // Scan toward the wall normal if (Physics.Raycast(transform.position, -PreviousWallNormal, out hit, 2.0f)) { hit_wall = true; } } else if (IsWallClimbing()) { // Scan toward the wall normal at both head and stomach height if (Physics.Raycast(transform.position, -PreviousWallNormal, out hit, 2.0f)) { hit_wall = true; } else if (Physics.Raycast(transform.position + (transform.up * (cc.height / 2 - cc.radius)), -PreviousWallNormal, out hit, 2.0f)) { hit_wall = true; } } else { // Scan forward and sideways to find a wall if (Physics.Raycast(transform.position, transform.right, out hit, 2.0f)) { hit_wall = true; } else if (Physics.Raycast(transform.position, -transform.right, out hit, 2.0f)) { hit_wall = true; } else if (Physics.Raycast(transform.position + (transform.up * (cc.height / 2 - cc.radius)), transform.forward, out hit, 2.0f)) { hit_wall = true; } } // Update my current state based on my scan results if (hit_wall && hit.normal.y > -0.17f && hit.normal.y <= 0.34f) { UpdateWallConditions(hit.normal); } if (IsWallClimbing() && !isHanging) { // Scan for ledge if (Physics.Raycast(transform.position + (transform.up * (cc.height / 2 - cc.radius)), -PreviousWallNormal, out hit, 2.0f)) { Vector3 LedgeScanPos = transform.position + (transform.up * cc.height / 2) + LedgeClimbOffset * transform.forward; if (Physics.Raycast(LedgeScanPos, -transform.up, out hit, LedgeClimbOffset)) { if (CanGrabLedge() && Vector3.Dot(hit.normal, Physics.gravity) < -0.866f) { isHanging = true; } } } // If all ledge climb conditions are met, climb it to the surface on top // and clear all wall conditions } } lastTrigger = null; }