public override void OnInspectorGUI() { serializedObject.Update(); DrawDefaultInspector(); MovingPlatformBehaviour platformScript = (MovingPlatformBehaviour)target; if (GUILayout.Button("Set Point A")) { platformScript.SetPointA(); } if (GUILayout.Button("Set Point B")) { platformScript.SetPointB(); } if (GUILayout.Button("Reset to Point A")) { platformScript.ResetToStartPosition(); } if (GUILayout.Button("Create Platform Path")) { platformScript.CreatePlatformPath(); } if (GUILayout.Button("Set Platform Path")) { platformScript.SetPlatformPath(); } serializedObject.ApplyModifiedProperties(); }
void FixedUpdate() { moveableGround = null; Collider[] colliders = Physics.OverlapSphere(transform.position + Vector3.down, 0.3f); for (int i = 0; i < colliders.Length; i++) { if (colliders[i].gameObject != gameObject) { moveableGround = colliders[i].GetComponent <MovingPlatformBehaviour>(); //anders kan de kubus zelf als collider worden beschouwd. } } if (moveableGround) { transform.position += moveableGround.movement; } var pos = transform.position; if (pos.x < Game.current.minX || pos.x > Game.current.maxX || pos.y < Game.current.minY || pos.y > Game.current.maxY) { RandomPlatformGenerator.current.ReplaceTarget(this); } }
private static void UsePlateforRpc(MovingPlatformBehaviour Plateform, bool isLeft) { MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncPlateform, SendOption.None, -1); messageWriter.Write(isLeft); AmongUsClient.Instance.FinishRpcImmediately(messageWriter); Coroutines.Start(UsePlatform(Plateform, isLeft)); }
private bool CheckOnCollision(Vector3 v, float checkradius) { Collider[] colliders = Physics.OverlapSphere(transform.TransformPoint(v), checkradius); for (int i = 0; i < colliders.Length; i++) { if (colliders[i].gameObject != gameObject) { moveableGround = colliders[i].GetComponent <MovingPlatformBehaviour>(); //anders kan de kubus zelf als collider worden beschouwd. return(true); } } return(false); }
private void OnCollisionEnter(Collision collision) { var colPoint = collision.GetContact(0); bool onTop = transform.position.y >= colPoint.point.y; inAir = !onTop; if (collision.collider.CompareTag("MovingPlatform") && onTop) { movingPlatform = collision.transform.GetComponent <MovingPlatformBehaviour>(); movingPlatformTransform = movingPlatform.transform; onMovingPlatform = true; } if (collision.collider.CompareTag("DamageTrigger")) { Health--; } }
private void Start() { if (canActivate) { activatingPlatformBehaviour = GetComponent <ActivatingPlatformBehaviour>(); } if (canMove) { movingPlatformBehaviour = GetComponent <MovingPlatformBehaviour>(); } if (canRotate) { rotatingPlatformBehaviour = GetComponent <RotatingPlatformBehaviour>(); } }
public void AddOrRemoveBehaviours(int behaviourIndex, bool isAdding) { switch (behaviourIndex) { case 0: if (isAdding) { activatingPlatformBehaviour = gameObject.AddComponent <ActivatingPlatformBehaviour>(); canActivate = true; } else { DestroyImmediate(activatingPlatformBehaviour); canActivate = false; } break; case 1: if (isAdding) { rotatingPlatformBehaviour = gameObject.AddComponent <RotatingPlatformBehaviour>(); canRotate = true; } else { DestroyImmediate(rotatingPlatformBehaviour); canRotate = false; } break; case 2: if (isAdding) { movingPlatformBehaviour = gameObject.AddComponent <MovingPlatformBehaviour>(); canMove = true; } else { DestroyImmediate(movingPlatformBehaviour); canMove = false; } break; } }
private static IEnumerator UsePlatform(MovingPlatformBehaviour Plateform, bool isLeft) { PlateformIsUsed = true; Plateform.IsLeft = isLeft; Plateform.transform.localPosition = (Plateform.IsLeft ? Plateform.LeftPosition : Plateform.RightPosition); Plateform.IsDirty = true; Vector3 sourcePos = Plateform.IsLeft ? Plateform.LeftPosition : Plateform.RightPosition; Vector3 targetPos = (!Plateform.IsLeft) ? Plateform.LeftPosition : Plateform.RightPosition; yield return(Effects.Wait(0.1f)); yield return(Effects.Slide3D(Plateform.transform, sourcePos, targetPos, PlayerControl.LocalPlayer.MyPhysics.Speed)); Plateform.IsLeft = !Plateform.IsLeft; yield return(Effects.Wait(0.1f)); PlateformIsUsed = false; yield break; }
public void Move(float horizontal, bool jump) { if (disabletimer > 0) { return; } moveableGround = null; onLeft = CheckOnCollision(leftWallCheckVector, 0.3f); //Cirkels opzij groter. onRight = CheckOnCollision(rightWallCheckVector, 0.3f); onCeiling = CheckOnCollision(ceilingCheckVector, 0.3f); onGround = CheckOnCollision(groundCheckVector, 0.1f); //sets drag when not in air if (horizontal == 0 && onGround && !jump) { if (GetComponent <Rigidbody>().drag < 100) { rbody.drag++; } } else { rbody.drag = 0; } Vector3 moveVector = Vector3.zero; //moving horizontal if (Mathf.Abs(rbody.velocity.x) < player.maxSpeed || Mathf.Sign(horizontal) == -Mathf.Sign(rbody.velocity.x)) { moveVector.x = horizontal * player.acc; } //reduce speed after speeding up to much else if (Mathf.Abs(rbody.velocity.x) > player.maxSpeed) { float difference = 0; if (rbody.velocity.x < 0) { difference = -player.maxSpeed - rbody.velocity.x; } else { difference = player.maxSpeed - rbody.velocity.x; } moveVector.x = Mathf.Lerp(difference, 0, 0.5f); } //jumping if (jump) { disabletimer = disableTime; if (onGround) { moveVector.y = player.jumpforce; } else if (onLeft) { moveVector.x = player.jumpforce; moveVector.y = player.jumpforce; } else if (onRight) { moveVector.x = -player.jumpforce; moveVector.y = player.jumpforce; } } rbody.AddForce(moveVector); }
public void RemovePlatform() { platform = null; }
public void SetPlatform(MovingPlatformBehaviour p) { platform = p; }