// Use this for initialization public void Init(float Speed) { mSpeed = Speed; GroundMovement GrCmp = GetComponent <GroundMovement>(); if (GrCmp) { GrCmp.Speed = mSpeed; } if (EnemyPrefab != null) { Enemies = new List <GameObject>(); //Create a save Enemies int nEnemies = Random.Range(1, MaxNumberOfEnemies); for (int i = 0; i < nEnemies; i++) { GameObject Enemy = Instantiate(EnemyPrefab, this.transform.position, Quaternion.identity); EnemyBehaviour EnBCmp = Enemy.GetComponent <EnemyBehaviour>(); if (EnBCmp) { EnBCmp.Init(this.gameObject, mSpeed); } Enemies.Add(Enemy); } } else { Debug.LogError("No Enemy Prefab set"); } }
//the horizontal offset for climbing the target (0 is recommended), will be set by object to climb //private float xOffset = 0f; // Use this for initialization void Start() { playerBody = GetComponent <Rigidbody2D>(); playerAnimation = GetComponent <Animator>(); groundScript = GetComponent <GroundMovement>(); ropeBoxChecker = GetComponent <BoxCollider2D> (); }
void Start() { dino = FindObjectOfType <Dino>(); enemySpawn = FindObjectOfType <EnemySpawn>(); groundMovement = FindObjectOfType <GroundMovement>(); timeToIncreaseDifficulty = Time.time + interval; }
private void Start() { controller = GetComponent <CharacterController>(); ground = GetComponent <GroundMovement>(); fly = GetComponent <FlyingMovement>(); Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; }
// Use this for initialization public void Init(GameObject Building, float Speed) { mBuilding = Building; GrCmp = GetComponent <GroundMovement>(); if (GrCmp) { GrMvment = GrCmp; GrCmp.Speed = Speed; } }
// Use this for initialization void Start() { isDeath = false; counter = GetComponent <Score> (); shadowScript = GetComponent <shadowWalk> (); groundScript = GetComponent <GroundMovement> (); ladderScript = GetComponent <LadderMovement> (); pushPullScript = GetComponent <PushPullMovement> (); playerBody = GetComponent <Rigidbody2D> (); playerAnimation = GetComponent <Animator>(); }
public void TestUnderGroundMovement() { var movement = new GroundMovement(); var monster = new Monster { MonsterIndex = 1, Position = 1 }; movement.Move(monster); Assert.True(monster.Position == 2 && monster.MonsterIndex == 1); }
// Use this for initialization protected override void Start() { base.Start(); keeper = GetComponent <PathKeeper>(); target = GameObject.Find("Player"); targetDamageable = target.GetComponent <IDamageable>(); targetKeeper = target.GetComponent <PathKeeper>(); rb = GetComponent <Rigidbody>(); weapon = transform.Find("SwordPivotEnemy").gameObject; movement = GetComponent <GroundMovement>(); }
// Use this for initialization protected override void Start() { base.Start(); keeper = GetComponent <PathKeeper>(); target = GameObject.Find("Player"); targetDamageable = target.GetComponent <IDamageable>(); targetKeeper = target.GetComponent <PathKeeper>(); rb = GetComponent <Rigidbody>(); movement = GetComponent <GroundMovement>(); anim = transform.Find("BlobBoiModel").GetComponent <Animator>(); anim.SetFloat("RunBlend", 0f); }
protected override void Move() { if (GroundMovement != null) { Grounded = GroundMovement.TryStickToGround(false); } if (!Grounded) { Movement.AirMove(); } base.Move(); }
// Use this for initialization void Start() { //haetaan kaikki tarvittavat komponentit rb = GetComponent <Rigidbody>(); healthSystem = GetComponent <HealthSystem>(); healthSystem.dieHandler = OnDie; keeper = GetComponent <PathKeeper>(); cameraTarget = GameObject.Find("CameraTarget"); movement = GetComponent <GroundMovement>(); movement.OnHitGround = OnHitGround; anim = transform.Find("PlayerModel").GetComponent <Animator>(); damageBlinker = GetComponent <MaterialBlinker>(); footStepHandler = transform.Find("PlayerModel").GetComponent <FootstepHandler>(); footStepHandler.FootStepHandler = Footstep; //animaatiot anim.SetFloat("RunBlend", 0f); animBaseLayer = anim.GetLayerIndex("BaseLayer"); animFallLayer = anim.GetLayerIndex("FallLayer"); animHurtLayer = anim.GetLayerIndex("HurtLayer"); animJumpLayer = anim.GetLayerIndex("JumpLayer"); animLandingLayer = anim.GetLayerIndex("LandingLayer"); anim.GetBehaviour <AttackLayerScript>().OnSlashEndHandler = OnSlashEnd; swordHitbox.SetActive(false); //lataa pelaajan tilanne tallennuksesta GameData.Player playerData = GameDataManager.Instance.GameData.player; if (playerData.firstCheckPointReached) { //paikka, suunta ja polku transform.position = playerData.position.toVector3(); transform.rotation = playerData.rotation.toQuaternion(); keeper.currentSpline = GameObject.Find(playerData.pathName).GetComponent <BezierSpline>(); //health healthSystem.currentHealth = playerData.currentHealth; healthSystem.maxHealth = playerData.maxHealth; } //siirrä kamera pelaajan paikalle cmDefaultCamera = GameObject.FindGameObjectWithTag("CMDefaultCamera"); mainCamera = GameObject.FindGameObjectWithTag("MainCamera"); if (cmDefaultCamera != null) { cmDefaultCamera.SetActive(false); mainCamera.SetActive(false); cmDefaultCamera.transform.position = transform.position; mainCamera.transform.position = transform.position; StartCoroutine(ActivateCameras()); } }
// Use this for initialization protected override void Start() { base.Start(); keeper = GetComponent <PathKeeper>(); target = GameObject.Find("Player"); targetDamageable = target.GetComponent <IDamageable>(); targetKeeper = target.GetComponent <PathKeeper>(); rb = GetComponent <Rigidbody>(); movement = GetComponent <GroundMovement>(); healthSystem = GetComponent <HealthSystem>(); healthSystem.dieHandler = OnDie; damageBlinker = GetComponent <MaterialBlinker>(); anim = GetComponentInChildren <Animator>(); anim.SetFloat("RunBlend", 0f); }
private void FixedUpdate() { if (groundMovements == null || groundMovements.Count == 0) { return; } GroundMovement groundExiting = null; foreach (var groundMovement in groundMovements) { groundMovement.Drag(transform.forward, velocity); if (!groundMovement.gameObject.activeInHierarchy || !groundMovement.InsideWaterStream) { groundExiting = groundMovement; } } if (groundExiting != null) { ReleaseGroundMovement(groundExiting); } }
public void Start() { _controller = GetComponent<GroundMovement> (); _isFacingRight = transform.localScale.x > 0; }
// Use this for initialization void Start() { playerAnimation = GetComponent <Animator> (); playerBody = GetComponent <Rigidbody2D>(); groundScript = GetComponent <GroundMovement> (); }
// Start is called before the first frame update void Start() { offset = transform.position - player.transform.position; Cursor.lockState = CursorLockMode.Locked; script = player.GetComponent <GroundMovement>(); }
private void RegisterGroundMovement(GroundMovement groundMovement) { groundMovements.Add(groundMovement); groundMovement.EnterWaterStream(); }
public void ReleaseGroundMovement(GroundMovement groundMovement) { groundMovement.LeaveWaterStream(); groundMovements.Remove(groundMovement); }
// Start is called before the first frame update void Start() { GroundPlayer = GameObject.Find("GroundedPlayer").GetComponent <GroundMovement>(); }
public Giant() { movement = new GroundMovement(); attackType = new PunchAttack(); level = new LevelOne(); }
protected virtual void Move() { // moving { Vector2 origin; float boxHeight; //LayerMask GROUND_MASK = LayerMask.GetMask("Default"); LayerMask GROUND_MASK = f_movement.Mask; // On the ground, the feet will be ignored, since they often walk through the floor a bit if (Grounded) { origin = transform.TransformPoint(new Vector2(0, f_height * 0.75f)); boxHeight = f_height / 2f * transform.localScale.y; } else // in air { origin = transform.TransformPoint(new Vector2(0, f_height * 0.55f)); boxHeight = f_height * 0.9f * transform.localScale.y; //if (Vector2.Angle(transform.up, Velocity) > 45) { if (Velocity.y <= 0 || f_movement is AirMovement) { boxHeight *= 0.9f; } } RaycastHit2D hit; // Trying to move // When there is a collision, the character only gets moved a bit and the velocity changes // It is then tried again if the character can move for (int i = 0; i < CONTROLLER_SO.MAX_COLLISION_ITERATIONS; ++i) { hit = Physics2D.BoxCast(origin, new Vector2(HalfWidth * 2f - 0.05f, boxHeight - 0.05f), transform.eulerAngles.z, Velocity, Velocity.magnitude / 60f, GROUND_MASK); if (hit) { if (hit.fraction == 0) { if (Mathf.Abs(hit.point.x - transform.position.x) < 0.2f) { if (this is Player) { m_playerMovement += (Vector2.right * 0.1f * ((hit.transform.position.x < transform.position.x) ? 1 : -1)).Abs(); } transform.position = transform.position + (Vector3)Vector2.right * 0.1f * ((hit.transform.position.x < transform.position.x) ? 1 : -1); return; } else { // TODO; not sure about this one // necessary but does some stupid stuff GroundMovement?.TryStickToGround(true); //transform.position = transform.position + (Vector3)(hit.normal * 0.1f + Velocity.normalized * 0.05f); } } else { // updating the position by the fraction of the velocity which worked if (this is Player) { m_playerMovement += ((hit.fraction - 0.1f) / 60f * Velocity).Abs(); } transform.position = transform.position + (hit.fraction - 0.1f) / 60f * (Vector3)Velocity; } //Vector2 parallel = Vector2.Perpendicular(hit.normal); Vector2 parallel = Vector3.Cross(hit.normal, Vector3.forward); float parFraction = Vector2.Dot((1 - hit.fraction + 0.1f) / 60f * Velocity, parallel); // this cancels out the Velocity in which the character is moving at the moment Velocity = (60f * parFraction * parallel); // the character will NOT move the rest of the movement here anymore; this will happen in the next iteration step } else { // moving normally if (this is Player) { m_playerMovement += (Velocity / 60f).Abs(); } transform.position = transform.position + (Vector3)Velocity / 60f; // Since the velocity has not been updated, this process can be ended break; } } } Orient(); f_animator.SetFloat("X", Velocity.x); f_animator.SetFloat("Y", Velocity.y); }
public void Start() { _controller = GetComponent <GroundMovement> (); _isFacingRight = transform.localScale.x > 0; }
public Giant(ILevel level) { movement = new GroundMovement(); attackType = new PunchAttack(); this.level = level; }