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 /
  • Help Room /
avatar image
0
Question by Gann4Life · Sep 02, 2016 at 01:59 AM · c#error

Unity 5 doesn't detect some positions in Vector3

Hello guys! Im trying to acces to Vector3.back but i dont know why it doesn't work, but using Vector3.forward, left, up, these are working correctly. What is the error here? Im using Unity 5.4.0b17 (64-bit) Personal.

The code: using UnityEngine; using System.Collections;

 public class Balance : MonoBehaviour {
     public int StandForce;
     public float horizontalSpeed = 2.0f;
     public float verticalSpeed = 0.0f;
     public KeyCode crouch;
     public KeyCode forw;
     public KeyCode backw;
 
     void Start(){
         BoxCollider collider = gameObject.GetComponent ("BoxCollider") as BoxCollider;
     }
 
     void Update(){
         float h = horizontalSpeed * Input.GetAxis ("Mouse X");
         float v = verticalSpeed * Input.GetAxis ("Mouse Y");
         transform.Rotate (v, h, 0);
 
         if (Input.GetKey (forw)) {
             Vector3 forward = transform.TransformDirection (Vector3.forward) * 1;
             GetComponent<Rigidbody> ().AddForce (transform.forward * StandForce, ForceMode.Acceleration);
             GetComponent<Rigidbody> ().useGravity = true;
         }
 
         if (Input.GetKey (backw)) {
             Vector3 back = transform.TransformDirection (Vector3.back) * 1;
             GetComponent<Rigidbody> ().AddForce (transform.back * StandForce, ForceMode.Acceleration);
             GetComponent<Rigidbody> ().useGravity = true;
         }
 
         if (Input.GetKeyDown (crouch)) {
             GetComponent<Collider>().GetComponent<BoxCollider> ().enabled = false;
         }
 
         if (Input.GetKeyUp (crouch)) {
             GetComponent<Collider>().GetComponent<BoxCollider> ().enabled = true;
         }
     }
 
     void OnTriggerStay(){
         Vector3 up = transform.TransformDirection (Vector3.up) * 1;
         GetComponent<Rigidbody> ().AddForce (transform.up * StandForce, ForceMode.Acceleration);
         GetComponent<Rigidbody> ().useGravity = true;
     }
 }

Images:

alt text alt text

What does the script? "some spam"

https://www.youtube.com/watch?v=ZKwWiMe2W0Y

consoleerror.png (46.6 kB)
monoalert.png (30.2 kB)
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 Cynikal ♦ · Sep 02, 2016 at 02:53 AM 0
Share

What exactly is it doing? Nothing at all? Or just...weird behavior?

Also, your images are showing up as forbidden. Use a public listing site.

avatar image Gann4Life Cynikal ♦ · Sep 03, 2016 at 03:44 PM 0
Share

$$anonymous$$akes a rigidbody balance/float when enter on trigger, i used a box collider, works similar a raycast. Then with some keys it can move in air, impulse the rigidbody and nothing more. But in the values i used normal floats and negative floats, it works, but i dont know why transform.back doesn't work. I cant remember other orientations that doesn't work.

avatar image doublemax Gann4Life · Sep 03, 2016 at 04:37 PM 0
Share

but i dont know why transform.back doesn't work

"Doesn't work" is a little misleading here. It's a compiler error, because Transform just has no member by that name. But (-transform.forward) should work.

BTW: It would be nice if you remove lines that do nothing from your code before posting. It makes it easier for other people to understand the code.

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.

Follow this Question

Answers Answers and Comments

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

How to convert an inputfield's string to an int? (C#) 1 Answer

[C#] The left-hand side of an assignment must be a variable, a property or an indexer 0 Answers

I have an error on a C# script @username 2 Answers

Nav Mesh Problem with SetDestination 1 Answer

Using a reference for another script in a method issue. 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