Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Kikottan · Jan 28, 2017 at 09:07 AM · charactercontrollercomponentbeginners

Character Movement component

hello,

I am new to Unity and I need help!

I am currently watching a tutorial for beginners and I have managed to get to the end pretty well as I was able to follow the instructions perfectly. However the guy on the video adds a component called ""character movement" which on my Unity 5.5 doesn t exist! I ve been trying to use thrid person or first person charact components but they seem to mess u everywthing! I ve been looking everywhere and even on the internet i haven t found a solution.

Please somebody help me!

Comment
Add comment · Show 4
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 AR_Rizvi · Jan 28, 2017 at 09:51 AM 1
Share

may be its his own Script made to move the Character you should check the tutorial further i am sure he will explain that script follow the tutorial closely

avatar image Kikottan AR_Rizvi · Jan 29, 2017 at 10:36 PM 0
Share

i ve watched the tutorial closely more tha once and followed it carefully but it doesn t explain that part, i just don t seem to have that particular component.

avatar image Sheepers · Jan 28, 2017 at 09:23 PM 0
Share

You may be confusing it with the "character controller" physics component, but most people do write their own script for character movement.

avatar image Kikottan Sheepers · Jan 29, 2017 at 10:41 PM 0
Share

so... i m going to write down how the tutorial proceeded:

  1. add component > physics > character controller

i did this part, then...

  1. add component > scripts > character movement

unfortunately, when i went to do that, there was not "character movement" component. I m VERY new to unity, but i have assumed he coded and saved previously. I m trying to code as well, i ve made my own script... but my character slowly sinks through the terrain ahah

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Scholand · Jan 28, 2017 at 11:59 PM

You Can use this for a smooth or direct 2DCamera Movement.

using UnityEngine; using System.Collections;

public class CameraMovment : MonoBehaviour {

 private Vector2 velocity;

 public float smoothTimeY;
 public float smoothTimeX;
 public float DownDeadPoint = 0;

 private GameObject player;

 void Start ()
 {
     player = GameObject.FindGameObjectWithTag("Player");
 
 }

 void FixedUpdate()
 {
     if(player == null)
     {
         player = GameObject.FindGameObjectWithTag("Player");
     }
     if (player == null)
     {
         Debug.Log("Error: no Player found");
         return;
     }


     float posX;
     if(player.transform.position.x >= 5)
     {
         posX = Mathf.SmoothDamp(transform.position.x, player.transform.position.x, ref velocity.x, smoothTimeX);
     }
     else
     {
         posX = Mathf.SmoothDamp(transform.position.x, 5, ref velocity.x, smoothTimeX);
     }

     float posY;
     if (player.transform.position.y >= DownDeadPoint)
     {
         posY = Mathf.SmoothDamp(transform.position.y, player.transform.position.y, ref velocity.y, smoothTimeY);
     }
     else
     {
         posY = Mathf.SmoothDamp(transform.position.y, DownDeadPoint, ref velocity.y, smoothTimeY);
     }

     transform.position = new Vector3(posX, posY, transform.position.z);
 }
 

}

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 Kikottan · Jan 29, 2017 at 10:43 PM 0
Share

wow... i ll try that thank you!

i went ahead and made a personal script, which it seems to work, but the character slowly sinks through the terrain. ahah

I will give a shot with yours and i ll let you know how it goes!

tnx again

avatar image
0

Answer by Kikottan · Jan 30, 2017 at 07:44 AM

let me upload the script i ve done...

using UnityEngine; using System.Collections;

public class PlayerController : MonoBehaviour {

 public float inputDelay = 0.1f;
 public float forwardVel = 12;
 public float rotateVel = 100;

 Quaternion targetRotation;
 Rigidbody rBody;
 float forwardInput, turnInput;

 public Quaternion TargetRotation
 {
     get {return targetRotation; }
 }

 void Start()
 {
     targetRotation = transform.rotation;
     if (GetComponent<Rigidbody>())
         rBody = (GetComponent<Rigidbody>());
     else
         Debug.LogError("The character needs a rigidbody.");

     forwardInput = turnInput = 0;
 }

 void GetInput()
 {
     forwardInput = Input.GetAxis("Vertical");
     turnInput = Input.GetAxis("Horizontal");
 }

 void Update()
 {
     GetInput();
     Turn();
 }

 void FixedUpdate()
 {
     Run();
 }

 void Run()
 {
     if (Mathf.Abs(forwardInput) > inputDelay)
     {
         //move
         rBody.velocity = transform.forward * forwardInput * forwardVel;
     }
     else
         //zero velocity
         rBody.velocity = Vector3.zero;
 }

 void Turn()
 {
     if (Mathf.Abs (turnInput) > inputDelay)
     {
         targetRotation *= Quaternion.AngleAxis(rotateVel * turnInput * Time.deltaTime, Vector3.up);
     }
     transform.rotation = targetRotation;
 }

}

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

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

6 People are following this question.

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

Related Questions

Object reference not set to an instance of an Object 1 Answer

Get raw script of a Unity component 2 Answers

Detect collision when changing character controller height 2 Answers

Trouble disabling and enabling components on charactercontroller 1 Answer

Increasing Camera "Bobbing" speed when character is sprinting 1 Answer


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