Unrealistic jump in C#
I'm using this code as gravitation (can't change this):
Vector3 direction = dragTo.transform.position - transform.position; transform.position += direction * gravity * Time.deltaTime;
When I use:
transform.position += transform.up * speed * Time.deltaTime;
to jump my character does a very short and unrealistic jump. Can I do this in another way?
Hi. This is a legitimate question, however it is not appropriate for Unity Answers and should not have been published from the moderator queue.
The reason is obvious:
Quoting the FAQ:
There exist multiple duplicate questions with answers if you were to do a search, either on Answers or on the Forum.
Your question isn't specific enough: asking for a script, asking multiple questions in one post or asking a question that could be either subjective or require extensive discussion (and thus belongs in the Forum).
Or google in the first place.
Don't take this as a negative response, ins$$anonymous$$d take the hint to do searches beforehand. :) This will also save you time because you just have to read and not write something everytime. ;)
Have a nice day.
Answer by TeohRIK · Dec 14, 2015 at 03:09 AM
Not sure you using Rigidibody component for your character or not.
If you using it, you can use force to simulate more realistic jump
if(Input.GetKeyDown(KeyCode.Space))
GetComponent<Rigidbody>().AddForce(Vector3.Up * Speed);
Scripting Reference: Rigidbody AddForce
Follow this Question
Related Questions
Make a rigidbody Jump (global up) 3 Answers
Multi-touch buttons 0 Answers
Problem with Jump Animation 0 Answers