Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by McFads1 · Dec 17, 2014 at 11:15 AM · c#physicsjumpanimationsrigid body

Jump animation won't move forwards

Hi!

So I have applied a jump animation to my 3rd person character controller. The issue is that the character won't move forward during the animation. The jump animation jumps in its place, does not jump forwards.

We've tried using rigidbody.AddForce (Vector3.up 200f) and rigidbody.AddForce (Vector3.forward 200f), but the object won't move. I put both of those functions in the void update() function to see if they'd be applied in every frame.

We already have the player moving forward by called an animation and holding "w". But the jump animation just stay's in its place and won't move forwards.

So its pretty much Move - Stop moving and jump - Move again.

Advice? Help?

Sorry I didn't post the code. Here it is.

 using UnityEngine;
 using System.Collections;
 
 public class PlayerMotor : MonoBehaviour {
 
     public GameObject lina;
     public GameObject teleport;
     private float _moveSpeed;
     private Animator _animator;
     public float turningSpeed = 3;
     public float jumpSpeed = 8.0f;
     public int countdown = 1;
     public float runSpeed = 5;
     // Use this for initialization
     //crap below
     void Start ()
     {
         _animator = GetComponent <Animator> ();
     }
    
     // Update is called once per frame
     void Update ()
     {
         if(countdown >=1)
             countdown -= 1;
 
         CharacterController controller = GetComponent<CharacterController> ();
 
         //----------------------------------------------------Forward
         if (controller.isGrounded)
         {
             Debug.Log ("Is Grounded");
             if (Input.GetKey (KeyCode.W) && Input.GetKey (KeyCode.Space) && countdown <=0)
             {
                 countdown = 90;
                 Debug.Log (transform.position);
                 controller.Move(Camera.main.transform.TransformDirection (transform.forward));
                 transform.position = new Vector3(teleport.transform.position.x,teleport.transform.position.y,teleport.transform.position.z);
                 //rigidbody.AddForce (5,5,5);
                 Debug.Log (transform.position);
                 _animator.SetBool ("Jump", true);
 
             }
         }
 
         if(Input.GetKey (KeyCode.W) && Input.GetKey (KeyCode.A)) //Move Forward while rotating 90 degrees left
         {
             transform.Rotate (Vector3.up, -90 *Time.deltaTime*turningSpeed);
             _moveSpeed = 1.0f;
         }
         else if(Input.GetKey (KeyCode.W) && Input.GetKey (KeyCode.D)) //Move Forward while rotating 90 degrees right
         {
             transform.Rotate (Vector3.up, 90 *Time.deltaTime*turningSpeed);
             _moveSpeed = 1.0f;
         }
         else if(Input.GetKey (KeyCode.S) && Input.GetKey (KeyCode.A))
         {
             transform.Rotate (Vector3.up, 90 *Time.deltaTime*turningSpeed);
             _moveSpeed = 0.0f-1.0f;
         }
         else if(Input.GetKey (KeyCode.S) && Input.GetKey (KeyCode.D))
         {
             transform.Rotate (Vector3.up, -90 *Time.deltaTime*turningSpeed);
             _moveSpeed = 0.0f-1.0f;
         }
         else if (Input.GetKey (KeyCode.W)) //Move Forward
         {
             _moveSpeed = runSpeed;
         }
         //-----------------------------------------------------Left
         else if (Input.GetKey (KeyCode.A))
         {
             transform.Rotate (Vector3.up, -90 *Time.deltaTime*turningSpeed);
             _moveSpeed = runSpeed;
         }
         //-----------------------------------------------------Back
         else if (Input.GetKey (KeyCode.S))
         {
             _moveSpeed = 0.0f-runSpeed;
         }
         //-----------------------------------------------------Right
         else if (Input.GetKey (KeyCode.D))
         {
 
             transform.Rotate (Vector3.up, 90 *Time.deltaTime*turningSpeed);
             _moveSpeed = runSpeed;
 
         }
         else if (Input.GetKey (KeyCode.Space) && controller.isGrounded && countdown <=0) //Find a way to jump FORWARD!
         {
             countdown = 90;
             _animator.SetBool ("Jump", true);
             transform.position = new Vector3(transform.position.x,1.5f,transform.position.z); //Teleport Up
         }
         else
         {
             _moveSpeed = 0.0f;
         }
 
 
         _animator.SetFloat ("Speed", _moveSpeed);
    
     }
 
     void OnTriggerEnter (Collider other)  //Item Pickup
     {
         if (other.gameObject.tag == "Pickup")
         {
             other.gameObject.SetActive (false);
             //count++;
             //SetCountText();
         }
     }
 }
Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image KiraSensei · Dec 17, 2014 at 11:16 AM 0
Share

Could you post your exact code ?

The code you posted has a syntax error in it.

 rigidbody.AddForce (Vector3.forward*200f)
avatar image EvilTak · Dec 17, 2014 at 12:27 PM 0
Share

@$$anonymous$$iraSensei: That is because the OP didn't use the code formatting, and thus it comes up italicized like this ;) @$$anonymous$$cFads1: Please don't ask your questions again and again. Why do you have two anyway?

avatar image KiraSensei · Dec 17, 2014 at 12:32 PM 0
Share

The problem I raised was the missing "*", not the italic words :)

avatar image EvilTak · Dec 17, 2014 at 12:34 PM 0
Share

@$$anonymous$$iraSensei: Try putting a word between two "*"s without quotes. This is the result!

avatar image KiraSensei · Dec 17, 2014 at 12:44 PM 0
Share

Ok I understand now :)

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by scorched_by_kami · Dec 17, 2014 at 01:36 PM

uh u can either try to make a custom animation on the animator tab which helps a bit and u dont need to use a script

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image McFads1 · Dec 17, 2014 at 06:21 PM 0
Share

How would I go about doing that exactly?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Jumping through the roof! 1 Answer

How do i incorporate a double jump ingame? 1 Answer

Multiple Cars not working 1 Answer

Interpolate problem? Jump isn't smooth... 1 Answer

Adding double jump to physics platformer kit? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges