• 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
Question by yusolaifdfer · Feb 23, 2013 at 02:37 PM · rigidbodyplayerobjectmovinghead

Moving an object in 3D Space ~ Complexity

Hello referring to my old question w$$anonymous$$ch seems to be unanswerable as the character controller and rigidbody don't work together. here . So I have changed my approach a bit, Q - How about a rigidbody in 3D space that can will be accelerated with a button lets say A and the player could control its movement on axis with the arrow keys.

And is there a possibility that I could add an object called 'head' make it the main object's c$$anonymous$$ld and move the head and the main object (sphere) will rotate and move towards it ?

Comment

People who like this

0 Show 0
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
Best Answer

Answer by MountDoomTeam · Feb 23, 2013 at 05:42 PM

Hello, well done for working on that question, it is by figuring out those 1st steps that you learn to understand unity very well, the worm game tutorial is quite good for learning character movement at some chapter in the tutorial. the worm game has a head, and some body segments that just follow weatherhead goes with smooth follow.

Here's the 1st movement script I did for unity it's for flying an aeroplane it's got some basics in it. I t$$anonymous$$nk the commented out code afterwards is perhaps the one from the worm game, it also has a fire button and you need an invisible GameObject in front of the player from where the bullets are spawned, although you could also just make them spawn at GameObject + certain distance. There is constant force, relative force, etc. Have a look on youtube for marble games? And also the worm game.

Good luck

 var speed = 15.0;
 var rotspd = 10.0 ;
 var bullitPrefab : Transform;
 
 
 function Update ()
 { 
 
 
 if ( Input.GetKey("mouse 1") )
  {constantForce.relativeForce = 15000 * Vector3.forward
 ;}
 else 
  {constantForce.relativeForce = Vector3.zero;}
     if(Input.GetButton("forwards"))
      { 
               transform.eulerAngles.x += rotspd * Time.deltaTime * 7;
      }             
      
           if(Input.GetButton("backwards"))
      { 
               transform.eulerAngles.x += -rotspd * Time.deltaTime * 7;
      }        
      
           if(Input.GetButton("left"))
     {
               transform.eulerAngles.y += -rotspd * Time.deltaTime * 7;
      }        
      
           if(Input.GetButton("right"))
      { 
              transform.eulerAngles.y += rotspd * Time.deltaTime * 7;
      }        
 
     
         if(Input.GetButton("Fire1")) 
       { 
      var bullit = Instantiate(bullitPrefab, transform.Find("spawnPoint").transform.position, Quaternion.identity);
       bullit.rigidbody.AddForce(transform.forward *8000);
      }
       
 }     
 
 /*var speed = 3.0;
 
 var rotateSpeed = 32.0;
 
 var bullitPrefab : Transform;
 
 function Update ()
 { 
     var controller : CharacterController=GetComponent(CharacterController);
     
     //Rot
     transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
     
     //fwd bck
     var forward = transform.TransformDirection(Vector3(0,0,1));
     var curSpeed = speed * Input.GetAxis ("Vertical");
 
     controller.SimpleMove(forward * curSpeed);
 
     
     
 if(Input.GetButtonDown("Fire1")) 
       { 
       var bullit = Instantiate(bullitPrefab, transform.Find("spawnPoint").transform.position, Quaternion.identity);
       bullit.rigidbody.AddForce(transform.forward *2000);
       }
 } 
 */
 
Comment

People who like this

0 Show 3 · 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 yusolaifdfer · Feb 24, 2013 at 06:14 AM 0
Share

Thank you for understanding the situation ;w; I really appreciate and the worm tutorial was my first tutorial for unity (tornadotwins rocks) but thing here is my object is in the space like real space out there and its going towards its goal and its gonna be for the android/ios the sphere will go forward (in deep the screen) and when the player tilt the phone it will move up/down left/right but still going deep with its own velocity

now I don't want to ask for code for iphone/android I will see that myself but first I have to get the correct approach to it and my player must be a rigidbody because in further gameplay depends upon collision and stuff :/

avatar image yusolaifdfer · Feb 24, 2013 at 12:48 PM 0
Share

If I could PM, then I will be able to explain more accurately how I need it to be, its too difficult the camera also Fs up with rigidbody and addforce, I couldn't even start with my game unless I have the basic player script set up

avatar image yusolaifdfer · Feb 25, 2013 at 02:21 PM 0
Share

God I can't believe this is so hard

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

10 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

Related Questions

Attach a Player to a moving GameObject 0 Answers

Parent Object 0 Answers

Player on moving object doesn't follow it Unity 5 0 Answers

Recursive Rigidbody Method 1 Answer

How to use tag for all players in the Instantiate. 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