public async Task <IActionResult> Edit(int id, [Bind("GroundedId,FleetCategoryId,DepartmentId,StationId,Remarks")] Grounded grounded) { if (id != grounded.GroundedId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(grounded); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GroundedExists(grounded.GroundedId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "Comment", grounded.DepartmentId); ViewData["FleetCategoryId"] = new SelectList(_context.FleetCategory, "FleetCategoryId", "Mileage", grounded.FleetCategoryId); ViewData["StationId"] = new SelectList(_context.Set <Station>(), "StationId", "StationName", grounded.StationId); return(View(grounded)); }
private void Awake() { mCannon = GetComponentInChildren <WP_TurGun>(); mGrounder = GetComponent <Grounded>(); mHealth = 100f; }
// Use this for initialization protected override void Awake() { base.Awake(); var hinf = new RaycastHit(); Grounded = Observable.EveryFixedUpdate() .Select(_ => Physics.Raycast(RaycastOrigin, Vector3.down, out hinf, Level.Instance.DistBetweenAnchors, LayerMask.GetMask("Bounds", "Blocks", "Characters"))) .ToReadOnlyReactiveProperty(true); Grounded.AddTo(this); Grounded.Subscribe(x => Anim.SetBool("Falling", !x)); ObservableHP = this.ObserveEveryValueChanged(x => x.CurHp) .ToReadOnlyReactiveProperty(CurHp); IsDead = ObservableHP .Select(x => x <= 0) .ToReadOnlyReactiveProperty(false); Rb.OnCollisionEnterAsObservable() .Select(c => c.collider.GetComponentInParent <GameCharacter>()) .Where(gc => gc && (gc.transform.position - transform.position).y < -Level.Instance.DistBetweenAnchors * .5f) .TakeUntil(IsDead.Where(x => x)) .Subscribe(gc => { target.Value = gc; gc.GetHit(); Rb.AddForce(Vector3.up * 3.5f, ForceMode.Impulse); }) .AddTo(this); }
private void OnEnable() { _rigidbody = GetComponent <Rigidbody>(); _inputReader = GetComponent <InputReader>(); _grounded = GetComponent <Grounded>(); _collider = GetComponent <CapsuleCollider>(); }
/// <summary> /// </summary> /// <param name="grounded">Grounded enemy that is seeking</param> public override void Initialize(Enemy grounded) { this.grounded = (Grounded)grounded; groundedSize = grounded.GetComponent <Collider2D>().bounds.extents; platformLayer = LayerMask.NameToLayer("Platform"); sr = grounded.GetComponent <SpriteRenderer>(); }
private void Awake() { rb = GetComponent <Rigidbody>(); grounded = GetComponentInChildren <Grounded>(); oilTrail = GetComponentInChildren <OilTrail>(); slideAudioComp = GetComponent <AD_Slide>(); Reset(null); }
public override void OnStateEnter() { _input = stateMachine.GetComponent <InputReader>(); _crouch = stateMachine.GetComponent <Crouch>(); _grounded = stateMachine.GetComponent <Grounded>(); _edgeDetect = stateMachine.GetComponent <EdgeDetect>(); _edgeDetect.enabled = false; }
[HideInInspector] public bool disableOverride; // bypass weird behaviour when enabling/disabling component private void OnEnable() { _rigidbody = GetComponent <Rigidbody>(); _input = GetComponent <InputReader>(); _grounded = GetComponent <Grounded>(); _stats = GetComponent <StatHolder>().held; disableOverride = false; }
void LateUpdate() { bool isGroundedNow = Physics.Raycast(transform.position, Vector3.down, maxGroundDistance); if (isGroundedNow && !isGrounded) { Grounded?.Invoke(); } isGrounded = isGroundedNow; }
void Start() { grounded = GetComponent <Grounded>(); _stateMachine = new PlayerStateMachine(); Idle = new IdleState(_stateMachine, this); Moving = new MovingState(_stateMachine, this); Jumping = new JumpingState(_stateMachine, this); _rb = GetComponent <Rigidbody2D>(); _stateMachine.Initialize(Idle); }
protected override void OnCollisionEnter2D(Collision2D collision) { base.OnCollisionEnter2D(collision); if (collision.transform.CompareTag("Ground")) { _grounded = true; _GroundedSound.Play("FX_RobotGrounded"); Grounded?.Invoke(gameObject); } }
private void Awake() { mStoredPath = new List <int>(); mStoredPath.Clear(); mEntity = GetComponent <AI_Controller>(); mWallChecker = GetComponent <AI_WallCheck>(); mGrounder = GetComponentInChildren <Grounded>(); mFootCaster = GetComponentInChildren <AI_FeetCaster>(); }
private void OnEnable() { _rigidbody = GetComponent <Rigidbody>(); _grounded = GetComponent <Grounded>(); _jump = GetComponent <Jump>(); _input = GetComponent <InputReader>(); _stats = GetComponent <StatHolder>().held; maxFuel = _stats.maxFuel; }
private void DestroyGrounder() { grounder.GroundFound -= DestroyGrounder; grounder.DestroyImmediate(); grounder = null; #if UNITY_MODULES_PHYSICS BodyPhysics.useGravity = true; BodyPhysics.isKinematic = false; BodyPhysics.velocity = Vector3.zero; #endif }
private void Awake() { Animator = GetComponent <Animator>(); Rigidbody = GetComponent <Rigidbody>(); Grounded = GetComponentInChildren <Grounded>(); SoundManager = FindObjectOfType <SceneConfiguration>().SoundManager; FindAllArmour(); HideAllArmour(); if (!DisableZoom) { SetMinZoom(); } LoadLevelStatus(); }
void LateUpdate() { // Check if we are grounded now. bool isGroundedNow = Physics.Raycast(RaycastOrigin, Vector3.down, distanceThreshold * 2); // Call event if we were in the air and we are now touching the ground. if (isGroundedNow && !isGrounded) { Grounded?.Invoke(); } // Update isGrounded. isGrounded = isGroundedNow; }
[SerializeField] private float holdTime = 1.0f; // how long you need to hold to trigger the effect void Start() { GameObject vcam = GameObject.FindGameObjectWithTag("MainVCam"); Grounded grounded = FindObjectOfType <Grounded> (); if (vcam != null) { transposer = vcam.GetComponent <CinemachineVirtualCamera> ().GetCinemachineComponent <CinemachineFramingTransposer> (); } if (grounded != null) { isGrounded = grounded.isGrounded; } }
private void FixedUpdate() { Debug.Log(IsGrounded); CCRotate(Input.GetAxis("Horizontal")); switch (g) { case Grounded.T: { Movetemp = Input.GetAxis("Vertical"); DirTemp = transform.forward; cc.Move(transform.forward * MoveSpeed * Movetemp * Time.deltaTime); IsGrounded = IsGroundCheck(); if (Input.GetKeyDown(KeyCode.Space)) { Debug.Log("GET"); Fall = new Vector3(0, JumpSpeed, 0); g = Grounded.I; } else if (!IsGrounded) { g = Grounded.I; } break; } case Grounded.I: { cc.Move((DirTemp * MoveSpeed * Movetemp + Fall) * Time.deltaTime); Fall += Physics.gravity * Time.deltaTime; if (Fall.y <= 0) { g = Grounded.F; } break; } case Grounded.F: { cc.Move((DirTemp * MoveSpeed * Movetemp + Fall) * Time.deltaTime); Fall += Physics.gravity * Time.deltaTime; IsGrounded = IsGroundCheck(); if (IsGrounded) { Fall = Vector3.zero; g = Grounded.T; } break; } } }
public async Task <IActionResult> Create([Bind("GroundedId,FleetCategoryId,DepartmentId,StationId,Remarks")] Grounded grounded) { if (ModelState.IsValid) { _context.Add(grounded); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "Comment", grounded.DepartmentId); ViewData["FleetCategoryId"] = new SelectList(_context.FleetCategory, "FleetCategoryId", "Mileage", grounded.FleetCategoryId); ViewData["StationId"] = new SelectList(_context.Set <Station>(), "StationId", "StationName", grounded.StationId); return(View(grounded)); }
// Use this for initialization void Start() { play_foot = false; prev_foot = play_foot; sounds.PlaySound("wind"); spawn_pos = transform.position + new Vector3(0, 10, 0); spawn_angle = transform.eulerAngles; last_angle = transform; UI = UI_obj.GetComponent <UI>(); UI_components = UI_obj.GetComponentsInChildren <RectTransform>(true); other_player = other_player_obj.GetComponent <PlayerOnTick>(); swimming = false; swim_first_time = false; playing = false; at_canon = false; show_canon = false; exited = true; entered = false; jumpable = true; boosting = false; trash_count = 0; boost_timer = 40; land_speed = walk_default; water_speed = swim_default; cam_cam = GetComponentInChildren <Camera>(); default_fov = cam_cam.fieldOfView; anim = GetComponentInChildren <ControlAnim>(); cam = GetComponentInChildren <CameraMech>(); cam_trans = cam.gameObject.transform; body_rb = GetComponent <Rigidbody>(); feet = GetComponentInChildren <Grounded>(); start_pos = transform; canon = canon_obj.GetComponent <CanonMech>(); canon_trans = canon_obj.GetComponentsInChildren <Transform>(true); canon_cam = canon_trans[6].gameObject; canon_cam_cam = canon_cam.GetComponent <Camera>(); spawn_cam_angle = cam_cam.gameObject.transform.eulerAngles; water_level = Water_Layer.transform.position.y; }
public override void OnStateEnter() { _inputReader = stateMachine.GetComponent <InputReader>(); _stats = stateMachine.GetComponent <StatHolder>().held; _motor = stateMachine.GetComponent <Motor>(); _crouch = stateMachine.GetComponent <Crouch>(); _grounded = stateMachine.GetComponent <Grounded>(); _falldmg = stateMachine.GetComponent <FallDamage>(); #region change motor vals _motor.speed = _stats.runSpeed; _motor.accelRate = _stats.runAccelRate; _motor.sprintHorizontalInputReductionMult = 1f; #endregion }
public override void OnStateEnter() { #region get comps _motor = stateMachine.GetComponent <Motor>(); _stats = stateMachine.GetComponent <StatHolder>().held; _input = stateMachine.GetComponent <InputReader>(); _grounded = stateMachine.GetComponent <Grounded>(); _jump = stateMachine.GetComponent <Jump>(); _crouch = stateMachine.GetComponent <Crouch>(); _collider = stateMachine.GetComponent <CapsuleCollider>(); #endregion #region change motor vals _motor.speed = _stats.crouchSpeed; _motor.accelRate = _stats.crouchAccelRate; #endregion }
/// <summary> /// Initalize the states and add them /// </summary> protected override void Start() { base.Start(); StateMachine = new CharacterStateMachine(this); falling = new Falling(); grounded = new Grounded(); motion = new Motion(); cutscene = new Cutscene(); // Add states StateMachine.AddState(StateName.Falling, falling); StateMachine.AddState(StateName.Grounded, grounded); StateMachine.AddState(StateName.Motion, motion); StateMachine.AddState(StateName.Cutscene, cutscene); }
public override void OnStateEnter() { _motor = stateMachine.GetComponent <Motor>(); _grounded = stateMachine.GetComponent <Grounded>(); _stats = stateMachine.GetComponent <StatHolder>().held; _falldmg = stateMachine.GetComponent <FallDamage>(); _jump = stateMachine.GetComponent <Jump>(); _crouch = stateMachine.GetComponent <Crouch>(); _crouch.crouching = true; if (_falldmg.landingFirm) { _motor.accelMult = Vector3.zero; timeToExit = 0.01f; _falldmg.landingFirm = false; } else if (_falldmg.landingHard) { _motor.accelMult = Vector3.zero; _motor.speed = _stats.runSpeed * 0.6f; _motor.accelRate = _stats.runAccelRate * 0.6f; timeToExit = 0.9f; _jump.disableOverride = true; _falldmg.landingHard = false; } else if (_falldmg.landingSplat) { _motor.accelMult = Vector3.zero; _motor.speed = _stats.runSpeed * 0.2f; _motor.accelRate = _stats.runAccelRate * 0.2f; timeToExit = 1.5f; _jump.disableOverride = true; _falldmg.landingSplat = false; } timer = 0; }
public override void OnStateEnter() { _input = stateMachine.GetComponent <InputReader>(); _stats = stateMachine.GetComponent <StatHolder>().held; _motor = stateMachine.GetComponent <Motor>(); _grounded = stateMachine.GetComponent <Grounded>(); _edgeDetect = stateMachine.GetComponent <EdgeDetect>(); _edgeDetect.enabled = true; _climb = stateMachine.GetComponent <Climb>(); toggle = false; _crouch = stateMachine.GetComponent <Crouch>(); _falldmg = stateMachine.GetComponent <FallDamage>(); #region change motor vals _motor.speed = _stats.airSpeed; _motor.accelRate = _stats.airAccelRate; _motor.sprintHorizontalInputReductionMult = 1f; #endregion }
// Start is called before the first frame update void Start() { enemies = new List <Enemy>(); foes = new List <IAttack>(); Flying enemy1 = new Flying(); Flying enemy2 = new Flying(); Grounded enemy3 = new Grounded(); Grounded enemy4 = new Grounded(); Underground enemy5 = new Underground(); enemies.Add(enemy1); enemies.Add(enemy2); enemies.Add(enemy3); enemies.Add(enemy4); enemies.Add(enemy5); foes.Add(enemy1); foes.Add(enemy2); foes.Add(enemy3); foes.Add(enemy4); foes.Add(enemy5); }
private void Awake() { grounded = GetComponentInChildren <Grounded>(); audJump = GetComponent <AD_Jump>(); playerState.jumping = false; }
// Update is called once per frame void FixedUpdate() { if (raceTimer.timeLeft <= 0.0f || countdown.timeLeft > 0.0f) { return; } Transform[] wheels = { frontLeftWheel, frontRightWheel, backLeftWheel, backRightWheel }; foreach (Transform wheel in wheels) { Vector3 velocity = rigidbody.GetPointVelocity(wheel.position); Vector3 forward = wheel.forward; Vector3 right = wheel.right; if (Vector3.Dot(forward, rigidbody.transform.forward) < 0.0f) { forward = -forward; right = -right; } bool isFrontWheel = Vector3.Dot(rigidbody.transform.forward, wheel.position - rigidbody.position) > 0.0f; if (isFrontWheel) { if (Mathf.Abs(wheel.localRotation.eulerAngles.y) > 90 && Mathf.Abs(wheel.localRotation.eulerAngles.y) < 270) { wheel.localRotation = Quaternion.Euler(0.0f, 180.0f + steer * maxSteer, 0.0f); } else { wheel.localRotation = Quaternion.Euler(0.0f, steer * maxSteer, 0.0f); } } Grounded grounded = wheel.GetComponent <Grounded>(); if (grounded.isGrounded) { forward = Vector3.Cross(right, grounded.groundNormal); //if (!isFrontWheel) { float accelerationMultiplier = Mathf.Clamp01(1.0f - Vector3.Dot(velocity, forward) / maxSpeed); rigidbody.AddForceAtPosition(accelerate * forward * maxAcceleration, wheel.position); float reverseMultiplier = Mathf.Clamp01(1.0f - Vector3.Dot(velocity, -forward) / maxReverseSpeed); rigidbody.AddForceAtPosition(-reverse * forward * maxReverseAcceleration, wheel.position); } float forwardFrictionWithBrake = forwardFrictionForce; float turningForceWithBrake = turningForce; //if (isFrontWheel) { forwardFrictionWithBrake = Mathf.Lerp(forwardFrictionForce, sideSlipForce, brake); //rigidbody.AddForceAtPosition(-brake * velocity, wheel.position); } //else { //turningForceWithBrake = Mathf.Lerp(turningForce, forwardFrictionForce, brake); } float slipAngle = Vector3.Angle(forward, velocity); float sideForce = sideForce = Mathf.Lerp(turningForceWithBrake, sideSlipForce, slipAngle / sideSlipAngle); float frictionMultiplier = Vector3.Dot(velocity, right); rigidbody.AddForceAtPosition(-frictionMultiplier * right * sideForce, wheel.position); frictionMultiplier = Vector3.Dot(velocity, forward); rigidbody.AddForceAtPosition(-frictionMultiplier * forward * forwardFrictionWithBrake, wheel.position); } } rigidbody.AddForce(-rigidbody.transform.up * rigidbody.velocity.magnitude * aerodynamicsForce); }
/// <summary> /// </summary> /// <param name="grounded">Enemy that is attacking</param> public override void Initialize(Enemy grounded) { this.grounded = (Grounded)grounded; rgbd = GetComponent <Rigidbody2D>(); }
void Start() { rigid = GetComponent <Rigidbody2D>(); grounded = GetComponent <Grounded>(); }