// Start is called before the first frame update void Start() { myRigidbody2D = GetComponent <Rigidbody2D>(); myConstantForce2D = GetComponent <ConstantForce2D>(); myLashHandler = GetComponent <LashHandler>(); triggerCollider = GetComponentInChildren <CapsuleCollider2D>(); }
public void StraightFire(Vector3 target) { //StartCoroutine(MoveTo(target)); ConstantForce2D force = GetComponent <ConstantForce2D>(); force.force = speed * (target - transform.position).normalized; }
//Create the projectile. Used by PlayerShipBehaviour too internal void CreateProjectile() { if (workingProjectileFireCooldown <= 0) //if projectile can be fired { Rigidbody2D shipRigid = GetComponent <Rigidbody2D>(); //used for getting current ship position GameObject newProjectile = Instantiate(projectileObject); //creates a new object, initially at 0,0 Rigidbody2D projectileRigid = newProjectile.GetComponent <Rigidbody2D>(); //set position + rotation of the projectile to that of the ship //newProjectile.transform.SetPositionAndRotation(shipRigid.transform.position, new Quaternion()); projectileRigid.transform.position = shipRigid.transform.position; //without transform. it spawns at 0,0 projectileRigid.transform.rotation = shipRigid.transform.rotation; ConstantForce2D projectileForce = newProjectile.GetComponent <ConstantForce2D>(); projectileForce.enabled = true; newProjectile.SetActive(true); ProjectileScript projectileScript = newProjectile.GetComponent <ProjectileScript>(); projectileScript.damage = projectileDamage; //sets the damage of the projectile projectileScript.ownerShip = gameObject; //sets the owner's ship to this workingProjectileFireCooldown = projectileFireCooldown; //increases the cooldown to the maximum } }
void Start() { rigid = this.GetComponent <Rigidbody2D>(); force = this.GetComponent <ConstantForce2D>(); playerController = GameObject.Find("Camera").GetComponent <PlayerController>(); }
//Initialization void Start() { player = this.gameObject; this.name = "Player"; //Add and applies Rigidbody2D to our player player.AddComponent <Rigidbody2D>(); rb = player.GetComponent <Rigidbody2D>(); rb.gravityScale = 2f; rb.constraints = RigidbodyConstraints2D.FreezeRotation; //Add and applies BoxCollider2D to our player player.AddComponent <BoxCollider2D>(); collide = player.GetComponent <BoxCollider2D> (); rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y); player.AddComponent <ConstantForce2D>(); gravityForce = player.GetComponent <ConstantForce2D>(); gravityForce.enabled = false; statePattern = player.GetComponent <StatePatternPlayer>(); //Gets the sprite component sprite = player.GetComponent <SpriteRenderer>(); GameObject healthBars = GameObject.Find("Health Bar"); health = healthBars.GetComponent <Health>(); }
void Awake() { //Get references p = GetComponent <Player>(); rb = GetComponent <Rigidbody2D>(); cf = GetComponent <ConstantForce2D>(); }
// Start is called before the first frame update void Start() { player = GameObject.FindWithTag("Player"); cam = GameObject.FindWithTag("MainCamera"); camScroll = GameObject.Find("CamScroll"); arrow = GameObject.Find("Flip/Arrow"); powerCube = GameObject.FindWithTag("PowerCube"); rb = camScroll.GetComponent <Rigidbody2D>(); cf = camScroll.GetComponent <ConstantForce2D>(); camScroll.transform.position = new Vector3(player.transform.position.x + camDistance, cam.transform.position.y, cam.transform.position.z); boss = GameObject.FindWithTag("Boss"); eyes = GameObject.Find("Boss/Eyes"); flip = GameObject.Find("Flip"); if (GameController.Instance.selectState == SelectState.BOSS) { boss.transform.position = new Vector3(cam.transform.position.x, cam.transform.position.y, player.transform.position.z + 5); boss.transform.SetParent(cam.transform); InvokeRepeating("DoFlipView", switchTime, switchTime); } GameController.Instance.DoStartGame(AudioController.Instance.gravityMusic); }
//Vector3 rotationVector = new Vector3 (180,0,0); // Use this for initialization void Start() { sr = GetComponent <SpriteRenderer> (); cf = GetComponent <ConstantForce2D> (); animator = GetComponent <Animator> (); //Time.timeScale = 0.01f; }
// Update is called once per frame void Update() { Vector3 CursorPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); CursorPos.z = transform.position.z; //Negligim la profunditat! Vector3 RelativeDir = (CursorPos - transform.position).normalized; //Vector que indica cap a on es troba el cursor respecte la nau Quaternion Look = Quaternion.FromToRotation(transform.up, RelativeDir); //El gir que hem de fer transform.rotation = Quaternion.Slerp(transform.rotation, transform.rotation * Look, Time.deltaTime * VelocitatGir); if (Input.GetButton("Fire1")) { Rb.AddForce(transform.up * VelocitatNau); SmokeEffect.GetComponent <ParticleSystem>().Play(); } else { SmokeEffect.GetComponent <ParticleSystem>().Stop(); } if (Input.GetButtonDown("Fire2")) { GameObject g = Instantiate(Bullet, transform.position, Quaternion.identity); g.GetComponent <Rigidbody2D>().gravityScale = 0f; ConstantForce2D cf = g.GetComponent <ConstantForce2D>(); cf.force = RelativeDir * bulletSpeed; } }
// Update is called once per frame void Update() { gravityDirection = NewBehaviourScript.activated; crateForce = GetComponent <ConstantForce2D>(); switch (gravityDirection) { case 0: crateForce.force = new Vector2(0, -20); break; case 1: crateForce.force = new Vector2(0, 20); break; case 2: crateForce.force = new Vector2(0, 0); break; case 3: crateForce.force = new Vector2(6, 0); break; case 4: crateForce.force = new Vector2(-6, 0); break; default: break; } }
//Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody2D>(); force = GetComponent <ConstantForce2D>(); animator = GetComponent <Animator>(); }
void onListItemDragEnded(Vector3 position, Sprite sprite) { GameObject instance = Instantiate(Resources.Load("InGameItem", typeof(GameObject)), null) as GameObject; instance.transform.position = position; SpriteRenderer spriteRenderer = instance.GetComponent <SpriteRenderer>(); if (spriteRenderer != null) { spriteRenderer.sprite = sprite; } Rigidbody2D instanceRigidbody = instance.GetComponent <Rigidbody2D>(); if (instanceRigidbody != null && sprite.name.Contains("Under")) { ConstantForce2D antiGravity = instanceRigidbody.gameObject.AddComponent <ConstantForce2D>(); antiGravity.force = new Vector3(0.0f, 9.81f, 0.0f); instanceRigidbody.gravityScale = 0; } Vector2 S = instance.GetComponent <SpriteRenderer>().sprite.bounds.size; instance.GetComponent <BoxCollider2D>().size = S; instance.GetComponent <BoxCollider2D>().offset = Vector2.zero;// ((S.x / 2), 0); if (m_onItemDragEnded != null) { m_onItemDragEnded(sprite.name); } }
// Start is called before the first frame update void Start() { Debug.Assert(state_ != null); rigidbody_ = GetComponent <Rigidbody2D>(); flapForce_ = GetComponent <ConstantForce2D>(); flapForce_.enabled = false; }
void Start() { body = GetComponent <Rigidbody2D>(); myCollider = GetComponent <CapsuleCollider2D>(); constanteForce = GetComponent <ConstantForce2D>(); arrowPivot.gameObject.SetActive(false); constanteForce.force = -transform.up * gravity; }
void Start() { _rb = GetComponent <Rigidbody2D>(); _cf = GetComponent <ConstantForce2D>(); _rb.AddRelativeForce(Vector2.right * _speed); _cf.relativeForce = new Vector2(_speed, 0); }
// Use this for initialization private void Start() { _cam = Camera.main; _rotateToPointer = GetComponent <RotateToPointer>(); _constantForce = GetComponent <ConstantForce2D>(); _rigidbody = GetComponent <Rigidbody2D>(); _audioSource = GetComponent <AudioSource>(); }
// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody2D>(); cf = GetComponent <ConstantForce2D>(); up = Resources.Load <Sprite>("Gravity/player_flipW"); down = Resources.Load <Sprite>("Gravity/player_sideW"); sr = GetComponent <SpriteRenderer>(); }
void Start() { SpriteRenderer = GetComponent <SpriteRenderer>(); raycastDistance = transform.localScale.x * GetComponent <BoxCollider2D>().size.x; constantForce2D = GetComponent <ConstantForce2D>(); constantForce2D.relativeForce = new Vector2(SpeedX, 0.0f); }
// Use this for initialization void Start() { timer = FindObjectOfType <Timer>(); zeroForce = new Vector2(0, 0); forwardForce = new Vector2(baseConstantForceX + MetaGameManager.Difficulty / difficultyScale, 0); constantForce2D = GetComponent <ConstantForce2D>(); StayStill(); }
void Start() { force = this.GetComponent <ConstantForce2D>(); head = GameObject.Find("Head"); headAnimator = head.GetComponent <Animator>(); rigid = this.GetComponent <Rigidbody2D>(); playerController = GameObject.Find("Camera").GetComponent <PlayerController>(); }
//private float forceBuf; void Awake() { rb = GetComponent <Rigidbody2D>(); cf = GetComponent <ConstantForce2D>(); mass = rb.mass; bufferTimer = BTIME; }
void Awake() { constForce = GetComponent <ConstantForce2D>(); rb = GetComponent <Rigidbody2D>(); initForce = constForce.relativeForce; lineRend = GetComponentInChildren <LineRenderer>(); lineRend.SetPosition(0, transform.position); lineRend.SetPosition(1, transform.position); }
void Start() { rigidbody = GetComponent <Rigidbody2D>(); force = GetComponent <ConstantForce2D>(); assignSprite(); beginningTime = Time.time; timeBeforeDeath = Random.Range(minTimeBeforeDeath, maxTimeBeforeDeath); }
protected virtual IEnumerator Die() { GameManager.instance.RemoveLight(m_light); // stage 1, enemy hurt and spinning hurt_source.clip = m_hurt_sounds[Random.Range(0, m_hurt_sounds.Length - 1)]; hurt_source.Play(); //PLAY DEATH PARTICLES m_path.canMove = false; can_attack = false; can_be_hit = false; UpdateCollisionsWithEnemy(); // FIX THIS, HAS NO DYING ANIM anim.SetTrigger("Hurt"); rb.constraints = RigidbodyConstraints2D.None; StartCoroutine(ExtinguishLight()); ConstantForce2D torque = GetComponent <ConstantForce2D>(); torque.torque = m_die_torque; // 10f float elapsed_time = 0f; Vector3 start_scale = new Vector3(1f, 1f, 1f); Vector3 start_pos = transform.position; Vector3 target_scale = new Vector3(0f, 0f, 1f); Vector3 target_pos = transform.position - new Vector3(0f, -.25f, 0f); float duration = .5f; while (elapsed_time < duration) { float timestep = elapsed_time / duration; transform.localScale = Vector3.Lerp(start_scale, target_scale, timestep); transform.position = Vector3.Lerp(start_pos, target_pos, timestep); elapsed_time += Time.deltaTime; yield return(null); } rb.constraints = RigidbodyConstraints2D.FreezeRotation; anim.transform.localScale = new Vector3(.25f, .25f, .25f); anim.SetTrigger("Die"); death_source.Play(); ExtinguishLight(); yield return(enemy_hurt_time); if (Random.Range(0, chance_of_drops) <= 0) { Instantiate(drops[Random.Range(0, drops.Length)], transform.position, Quaternion.identity); } GameManager.instance.levelManager.enemiesInScene.Remove(this); StopAllCoroutines(); Destroy(gameObject); }
void Start() { State = DinoState.Grounded; m_SpawnPosition = m_Rigidbody2D.position; m_Force2D = m_Rigidbody2D.gameObject.AddComponent <ConstantForce2D> (); m_Force2D.force = Vector2.up * m_JumpButtonHeldForce; m_Force2D.enabled = false; }
// Use this for initialization void Start() { gravitational = false; gravity = -981f; direccionGravedad = new Vector2(0, -1); Queco = GlobalStats.currentStats.jugador; Queco.GetComponent <GravChange>().gravitational = true; miCF = this.gameObject.GetComponent <ConstantForce2D>(); }
// Update is called once per frame void Update() { if (!getComponents) { rb = camScroll.GetComponent <Rigidbody2D>(); cf = camScroll.GetComponent <ConstantForce2D>(); getComponents = true; } }
// Start is called before the first frame update public override void Start() { base.Start(); constantForce2D = GetComponent <ConstantForce2D>(); if (stream) { stream.gameObject.SetActive(false); } }
void Awake() { chassis = GetComponent <Rigidbody2D>(); force = GetComponent <ConstantForce2D>(); drag = chassis.drag; ChangeGear((int)currentGear); }
// Use this for initialization void Start() { m_scoring = GameObject.Find("InGameData").GetComponent <Scoring>(); m_forceComponent = GetComponent <ConstantForce2D>(); m_windForceText = GameObject.Find("TextWindForce").GetComponent <Text>(); m_windForceImage = GameObject.Find("ImageWindForce").GetComponent <Image>(); m_currentWindForce = new Vector2(0, 0); m_maxPower = 0; }