• 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 /
  • Help Room /
avatar image
0
Question by $$anonymous$$ · Dec 28, 2015 at 09:31 AM · charactercontrollerhealthbar

Health and Movement not working together.

Ill try to make this reasonably short, but i have to show whole code to show the problem.

Movement script1:

using UnityEngine; using System.Collections;

public class PlayerControl : MonoBehaviour { float power = 10;

 void Update()
 {
     GetComponent<Rigidbody>().AddForce(new Vector3(Input.GetAxis("Horizontal") * power, 0.0f, Input.GetAxis("Vertical") * power));
 }

}

This doesn't work for shit. I tied it several times, and get all sorts of stupid messages including system collections being unnecessary but then upon removing it, i get other bs messages. So im done messing with that crap.

Movement script2

This one works with the health and destroy by contact type code, but its utter shit when it comes to actually colliding with something no matter what i set a rigid body and or collider. That and the movement is choppy and i tried to work with it but over all its utter crapola, especially in Unity 5.3.

 public class PlayerMovement : MonoBehaviour
 {
 
     public float speed = 3.0F;
     public float rotateSpeed = 3.0F;
 
      void Update()
     {
         transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed, 0);
         transform.Translate(Input.GetAxis("Horizontal") * Time.deltaTime, 0f, Input.GetAxis("Vertical") * Time.deltaTime);
   
     }
 }

So i am done with that crap and im not going to fuss with any crap like it any longer because it is utter shit with the latest updates. Vut hey at least if an eny bumbs me it knocks off some health points right? Yeah but if thats all its good for its worthless overall.

Movement Script 3

This one works great. I just need to figure out how to add the detection correctly along with a run movement option which i can add call animations to later. However, when it comes to an enemy dealing me damage it makes the health reduction, kill payer features utterly worthless. So while i get the actual proper physics in world with this one, but with anything like the others which are completely worthless, i basically have a boring ass game without a challenge of any kind where i can score points in a more or less "God Mode" which makes it all frankly about as "exciting" as staring at a corner of a room 24/7.

 using UnityEngine;
 
 public class PlayerControl : MonoBehaviour
 {
 
     //Variables
     public float speed = 3.0F;
     public float rotateSpeed = 3.0F;
     public float jumpSpeed = 8.0F;
     public float gravity = 20.0F;
     private Vector3 moveDirection = Vector3.zero;
 
 
     void Update()
     {
         CharacterController controller = GetComponent<CharacterController>();
         //Feed moveDirection with input.
         {
             transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed, 0);
             Vector3 forward = transform.TransformDirection(Vector3.forward);
             float curSpeed = speed * Input.GetAxis("Vertical");
             controller.SimpleMove(forward * curSpeed);
             //Jumping
             if (Input.GetButton("Jump"))
                 moveDirection.y = jumpSpeed;
         }
         //Applying gravity to the controller
         moveDirection.y -= gravity * Time.deltaTime;
         //Making the character move
         controller.Move(moveDirection * Time.deltaTime);
     }
 }

I need THIS ONE to work with Health, destroy by contact, etc the same way as if using the rigid body and capsule/box/sphere colliders. As i said none of the others work for shit when it comes to moving around and not get sent flying off in space .

I used the other code types with constrains on position Y and all three rotations of X,Y,Z, check "gravity" etc. And yes the stupid little "Ball/Cube/Whatever shape for the player," Is and has been Tagged Player.

I tried adding "collision detection" in Void Update. It didn't work. No errors, but it just literally did No Thing.

I used the siple destroy by contact script on the scripting section. Like i said, heath bars and all those other ones work fine now but with the shitty, choppy, unstable movement, or "no worky at all" scripts for player movement be, it FPS, TPS and all around BS, tested by simply dragging the life giving or taking targets mannually against the player. Then its "Oh looky" its working.

SO Please help me get the the stupid little line of code so i can use the working script, and show me where in the string that code is suppose to be placed! I apologize for my obvious anger, but since the latest updates this is the only type of movement that isn't utter garbage. Its just worthless for detection of anything.

P.S.

Don't waste my time or yours with some non-sense suggestion of creating an empty object and put the rigid and collider on that and then add the player to it using the controller. I actually tried that already too and it doesn't work and i haven't been "forgetting" any tags of anything.

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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

36 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 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

Healthbar creation without using UI, only with images/TEXTURE 0 Answers

How do I decrease a slider over time? 1 Answer

MaxHealth not updating after scene changes. 0 Answers

How to prevent Character Controller from falling of the edge? 6 Answers

choosing object and drop them from a machine 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