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 Bokaii · Jul 16, 2014 at 11:40 AM · rigidbodycharactercontrolleraddforcelaunch

Character Controller

I have a character controller, and I wan't it to launch in the direction of the camera, kinda like "Rigidbody.AddForce" but, I can't use a rigid body controller, because it stops the forward movement... :(

So, is there any way I could do this with the character controller, that comes with unity? :)

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by dsada · Jul 16, 2014 at 01:38 PM

use its SimpleMove function. You need to add a Vector3 that indicates the direction and the speed as well. Here is the Unity's example script:

 using UnityEngine;
 using System.Collections;
 
 [RequireComponent(typeof(CharacterController))]
 public class ExampleClass : MonoBehaviour {
     public float speed = 3.0F;
     public float rotateSpeed = 3.0F;
     void Update() {
         CharacterController controller = GetComponent<CharacterController>();
         transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed, 0);
         Vector3 forward = transform.TransformDirection(Vector3.forward);
         float curSpeed = speed * Input.GetAxis("Vertical");
         controller.SimpleMove(forward * curSpeed);
     }
 }
Comment
Add comment · Show 7 · 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 Bokaii · Jul 16, 2014 at 04:22 PM 0
Share

Thanks a lot for your answer! :D I will try this out! :D

avatar image Bokaii · Jul 16, 2014 at 04:32 PM 0
Share

I wrote a simple code, and it didn't work. It only goes forward on the z axis, not the y axis! :(

Code:

 using UnityEngine;
 using System.Collections;
 
 public class Pounce : $$anonymous$$onoBehaviour {
 
     public float Force = 20;
 
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
         CharacterController controller = GetComponent<CharacterController>();
 
         if(Input.GetButtonDown("Fire3")){
             controller.Simple$$anonymous$$ove(transform.FindChild("Camera").TransformDirection(Vector3.forward) * Force);
 
         }
     }
 }

avatar image dsada · Jul 16, 2014 at 05:49 PM 0
Share

Well the gravity applies to the character controller, so maybe that could be the problem. You would like to move the character upwards?

avatar image Bokaii · Jul 16, 2014 at 06:40 PM 0
Share

Yes in a way I would like to move the character upwards.

See, I'm making a game like "The Hidden" If you have played that? And I want to be able to launch my character like the hidden person in that game!

avatar image dsada · Jul 17, 2014 at 05:41 AM 0
Share

Well then you may want to use CharacterController.$$anonymous$$ove() ins$$anonymous$$d of Simple$$anonymous$$ove()

Show more comments

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to use AddForce on FPC 0 Answers

Physics AddForce reduced when 3 objects are colliding 1 Answer

Erratic Physics behaviour while testing in 2 computers 0 Answers

2D metroid boost ball 0 Answers

How to apply a force after launching the player? 0 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