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 /
This question was closed Apr 10, 2014 at 08:58 AM by MadJohny for the following reason:

Question is off-topic or not relevant

avatar image
0
Question by MadJohny · Apr 09, 2014 at 03:13 PM · charactercontrollerjumpteleportcharacter.move

(CharacterController) Jumping from other script

Hello, in my game I'm using a character controller for the player, and I took the movement script from the unity scripting reference and modified it a little bit.

 using UnityEngine;
 using System.Collections;
 
 [RequireComponent(typeof(CharacterController))]
 public class PlayerMovementScript: MonoBehaviour {
 
     float speed;
     Vector3 moveDirection;
     CharacterController cc;
     public MouseLookScript mouseLookScript;
     public PlayerStatsScript playerStatsScript;
 
     void Start () {
         cc = GetComponent<CharacterController>();
     }
 
     void Update() {
         speed = playerStatsScript.speed/2f;
 
         if (cc.isGrounded) {
             moveDirection.x = Input.GetAxis("Horizontal");
             moveDirection.z = Input.GetAxis("Vertical");
             moveDirection = transform.TransformDirection(moveDirection);
             moveDirection *= speed;
         }
         else {
             moveDirection.x = 0f;
             moveDirection.z = 0f;
         }
         cc.Move(new Vector3(moveDirection.x, -9.8f, moveDirection.z) * Time.deltaTime);
     }
 
     void LateUpdate () {
         transform.eulerAngles = new Vector3(transform.rotation.x, mouseLookScript.currentYRotation, transform.rotation.z);
     }
 }

The problem is, in my game, there is no jump button, but if the player picks an item, he would be able to perform a single jump, however this jump is telleporting the player 9 units up instead of jumping, if I try to jump using the movement script (changing moveDirection.y) it works, but I need to make the jump from another script.

From the special ability script this is the important line:

 cc.Move(Vector3.up * 10f);

So can anyone tell me how to fix this issue? Thanks in advance.

Comment
Add comment · Show 3
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 MadJohny · Apr 09, 2014 at 07:09 PM 0
Share

bumpy bump

avatar image koray1396 · Apr 09, 2014 at 08:40 PM 0
Share

Simply use AddForce or rigidbody.velocity.

avatar image MadJohny · Apr 09, 2014 at 09:08 PM 0
Share

I'm using a character controller

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Directional Jumping (Help) 2 Answers

why does character controller accelerate off ledges? 1 Answer

Help with animation... Please 2 Answers

can anyone help me to smooth the jump? 0 Answers

Player appears to teleport instead of adding force 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