- Home /
Teleportations instead of fluid jump motion
My problem
is apparently with as parallel as my code is to others i have found on youtube and unity's forum; it still seems to just want to teleport. i created a infinite side scroller last year and got back in to unity's software after a massive break so i do not know at this point if its because i need a refresher or if unity has further established its physics in the newest updates... anyways here is the code. Also the past side scroller was on unity2D so i do not know if their is a difference in how physics work.
public Rigidbody CharacterRb; private Vector3 moveInput; private Vector3 moveVelocity; private Vector3 VMove; public int CharacterSpeed; //jump var's public bool jumpUp; public float jumpSpeed; public float velocityY; //KeyCodes for button pads. public KeyCode Jump; //animation for later processes private Animator anim; private void Start() { CharacterRb = GetComponent<Rigidbody>(); anim = GetComponent<Animator>(); velocityY = CharacterRb.velocity.y; } private void Update() { float InputH = Input.GetAxis("Horizontal"); moveInput = new Vector3(InputH,0,0); moveVelocity = VMove * CharacterSpeed * moveInput.sqrMagnitude ; //Based on Positive or negative spectrum on the z axis will cause character to go back or forward or in this case right to left. if(InputH > 0f) { VMove = transform.forward; } else if (InputH < 0) { VMove = -transform.forward; } } private void FixedUpdate() { CharacterRb.velocity = moveVelocity; //Jumping if (jumpUp == true && Input.GetKeyDown(Jump)) { CharacterRb.AddForce(new Vector3 (0,jumpSpeed,0)); } } void Animating() { anim.SetFloat("Speed", CharacterRb.velocity.magnitude); } private void OnCollisionStay(Collision Jumpnow) { jumpUp = true; } private void OnCollisionExit(Collision Jumpoff) { jumpUp = false; }
any help or advice would be awesome, loved, and or greatly revered.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Jump with Character Controller 1 Answer
Jumping on moving platforms problem c# 1 Answer
Jumping in 3D 1 Answer