/// <summary> /// Remove a physics object from the manager if is present in the manager /// </summary> /// <param name="rigid"></param> public void RemoveCustomPhysics(CustomPhysics2D rigid) { if (allCustomPhysicsObjectsList.Contains(rigid)) { allCustomPhysicsObjectsList.Remove(rigid); } }
/// <summary> /// Add a physics object to the manager. /// </summary> /// <param name="rigid"></param> public void AddCustomPhysics(CustomPhysics2D rigid) { if (allCustomPhysicsObjectsList.Contains(rigid)) { return; } allCustomPhysicsObjectsList.Add(rigid); }
private void OnValidate() { if (!rigid) { rigid = GetComponent <CustomPhysics2D>(); } rigid.useGravity = simulateGravity; }
/// <summary> /// /// </summary> /// <param name="PhysicsComponent"></param> /// <returns></returns> public void RemoveCustomPhysics(CustomPhysics2D PhysicsComponent) { if (!AllActivePhysicsComponents.Remove(PhysicsComponent)) { Debug.LogWarning("The physics component that was passed in was not found in our physics manager. This may mean that you already removed it or it was never added."); return; } }
public void AddCustomPhysics(CustomPhysics2D PhysicsComponent) { if (!AllActivePhysicsComponents.Add(PhysicsComponent)) { Debug.LogWarning("You are trying to add a physics component that was already assigned to our Physics Manager."); return; } }
private void Awake() { rigid = GetComponent <CustomPhysics2D>(); anim = GetComponent <Animator>(); currentJumpsAvailable = maxAvailableJumps; rigid.OnGroundedEvent += this.OnGroundedEvent; rigid.OnAirborneEvent += this.OnAirborneEvent; }
private void OnValidate() { if (!rigid) { rigid = GetComponent <CustomPhysics2D>(); } jumpVelocity = 2 * jumpHeight / timeToHeight; rigid.gravityScale = jumpVelocity / timeToHeight / CustomPhysics2D.GRAVITY; rigid.terminalVelocity = jumpVelocity * rigid.fallingMultiplier; }
private void Start() { mainTarget = this.transform.parent; targetRigidbodyPhysics = mainTarget.GetComponent <CustomPhysics2D>(); cameraOffset = this.transform.position - mainTarget.position; this.transform.SetParent(null); associatedCamera = GetComponentInChildren <Camera>(); GameOverseer.Instance.AddObjectToDontDestroyOnLoad(this.gameObject); }
private void OnValidate() { if (!rigid) { rigid = GetComponent <CustomPhysics2D>(); } SetSpriteFlipped(isFacingRight); InitializeMovementParameters(); timeToReachJumpApex = Mathf.Max(.05f, timeToReachJumpApex); }
protected virtual void Awake() { GameOverseer.Instance.PhysicsManager.AddCollider2DToPhysicsManager(this); AssociatedPhysicsComponent = GetComponent <CustomPhysics2D>(); if (AssociatedPhysicsComponent && AssignedCollisionType != ECollisionType.PHYSICS) { Debug.LogWarning("Your collider contains a physics component, but is not set to CollisionType - 'Physics'. Are you sure this is correct?"); } else if (!AssociatedPhysicsComponent && AssignedCollisionType == ECollisionType.PHYSICS) { Debug.LogWarning("You collider does not contain a Physics component, but is assigned to CollisionType - 'Physics'. This can not work"); } PreviousBounds = CollisionFactory.GetNewBoundsInstance(AssociatedBounds.CollisionShape); UpdateColliderBounds(); //We want to update the collider bounds on awake PreviousBounds.CopyBoundsFrom(AssociatedBounds); //Make an exact copy for the first iteration }
private void Awake() { rigid = GetComponent <CustomPhysics2D>(); anim = GetComponent <Animator>(); currentJumpsAvailable = maxAvailableJumps; rigid.OnGroundedEvent += this.OnGroundedEvent; rigid.OnAirborneEvent += this.OnAirborneEvent; CommandInterpreter commandInterpreter = GetComponent <CommandInterpreter>(); if (commandInterpreter != null) { commandInterpreter.OnDirectionSetEvent += JoystickDirectionSet; } InitializeMovementParameters(); }
private void OnValidate() { if (!rigid) { rigid = GetComponent <CustomPhysics2D>(); } SetSpriteFlipped(isFacingRight); float gravity = (2 * heightOfJump) / Mathf.Pow(timeToReachJumpApex, 2); jumpVelocity = Mathf.Abs(gravity) * timeToReachJumpApex; jumpingAcceleration = gravity / CustomPhysics2D.GRAVITY_CONSTANT; rigid.gravityScale = jumpingAcceleration; if (maxAvailableJumps < 0) { maxAvailableJumps = 0; } if (maximumAirSpeed < 0) { maximumAirSpeed = 0; } }
protected void Start() { physicsCollider = GetComponent <BoxCollider2D>(); rigid = GetComponent <CustomPhysics2D>(); }
protected virtual void Awake() { rigid = GetComponent <CustomPhysics2D>(); projectileHitbox.onHurtboxEnteredEvent.AddListener(HitEnemy); }
private void Awake() { rigid = GetComponent <CustomPhysics2D>(); }
private void Awake() { rigid = GetComponent <CustomPhysics2D>(); associatedInteractionHandler = GetComponent <ProjectileInteractionHandler>(); //associatedInteractionHandler.AssociatedCharacterStats = associatedCharacterStats; }
private void Start() { rigid = GetComponent <CustomPhysics2D>(); jumpVelocity = 2 * jumpHeight / timeToHeight; rigid.gravityScale = jumpVelocity / timeToHeight / CustomPhysics2D.GRAVITY; }
private void Start() { rigid = GetComponent <CustomPhysics2D>(); anim = GetComponent <Animator>(); }
private void Awake() { rigid = GetComponent <CustomPhysics2D>(); associatedCollider = GetComponent <Collider2D>(); }