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 gckaufman · Jan 28, 2011 at 03:58 AM · movementvelocityspeedforce

Make an object move forward on its own

Im working on a game for the iphone where you tilt the screen to move a character but i want the character to move forward really fast on its own. Sounds kinda lame but i need help getting the player to move forward on its own. I tried rigidbody.AddForce and something that went like rigidbody.velocity(transform.position * 10) but it didnt work. Any suggestions at all would help

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

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Phil 5 · Jan 28, 2011 at 02:27 PM

Here two samples, one without and one with physics. If you use the physics one, be sure you have a rigidbody attached and a collider. Be sure the Drag of the rigidbody is 0.

float speed = 2.0f;

//Either this void Update() { transform.position += transform.forward speed Time.deltaTime; //I don't recall if "transform.position += something", if not, //user "transform.position = transform.position + something" }

//or that void FixedUpdate() { //this rigidbody.AddForce(transform.forward speed, ForceMode.VelocityChange); //or that for physics, but it's not the best way rigidbody.velocity = transform.forward speed; }

If you don't need physics in your game, I really suggest you the first solution to increase performance on iphone. I used C# but it should be easy to make it in javascript if you use that.

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
avatar image
1

Answer by Myth · Jan 28, 2011 at 05:08 AM

I am a bit of a noob in unity but,

for a constant movement have you considered something like this:

count = count + speed;

transform.position = Vector3(xpos, ypos, zpos+count);

Comment
Add comment · Show 2 · 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 ciooong · Jul 20, 2014 at 09:10 AM 0
Share

hi,

the script above helped me to get my gameobject move constantly. however, it'll keep on going on constant speed throughout the entire time. do u have any idea how to attach the speed value to a slider? my goal is to manouvre the moving speed fast and slow depending on users navigation.

thank you in advance,

cio

avatar image Connor_Epic · Aug 01, 2015 at 09:37 PM 0
Share

@ciooong it's simple. You would need to add a value from the slider, I'll try something. This is untested by the way so it may not work, it'll be something along these lines. // THIS IS JUST FOR THE FUNCTION AND IS IN C#

 public float speed;
 public float count;
 
 void adjustSpeed (float speed) {
 count += speed;
 transform.position = Vector3(xpos,ypos,zpos+count);
 }

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

Bullet not moving from script 3 Answers

Rigidbody speed in some senes different?! 1 Answer

Using rigidbody.AddForce and speeding the object 2 Answers

I do you control movements and apply other forces at the same time ? 0 Answers

Im using add force to make a 'ship' go forward, if i release the key is there any way to slow it gradually? 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