Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
This question was closed May 02, 2016 at 05:08 PM by stephen_george98 for the following reason:

The question is answered, right answer was accepted

avatar image
2
Question by stephen_george98 · May 01, 2016 at 05:31 AM · rotationtransformrotate objecttranslateobstacle

How to Make Object Spin While Moving?

I have the simplest script ever that moves the hammer and makes it rotate. This is it:

 using UnityEngine;
 using System.Collections;
 
 public class HammerMover : MonoBehaviour {
 
     
     void Update () {
 
         transform.Rotate (0f, 360f, 0f);
 
         transform.Translate (0.1f, 0f, 0f);
     
     }
 }

My question is this: How do I make the hammer rotate along the Y axis while it is moving down the X axis? Think like someone is throwing it at you. Right now, the hammer just moves in circles and I cannot figure out how to alter it. Thanks all :)

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

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Ali-hatem · May 01, 2016 at 11:46 AM

 public float speed,rotSpeed;
  void Update(){
             transform.position += Vector3.up * speed;
             transform.Rotate (rotSpeed,0,0);
         }
Comment
Add comment · Show 9 · 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 stephen_george98 · May 01, 2016 at 07:18 PM 0
Share

Thank you so much!! It worked perfect :)

avatar image Ali-hatem stephen_george98 · May 01, 2016 at 08:27 PM 2
Share

you welcome & you will love your previous problem as i did once because i found a beautiful way to rotate object around something .

avatar image Ali-hatem Ali-hatem · May 02, 2016 at 02:24 PM 2
Share
  public float diameter;
  public float RotateSpeed;
  public Transform target;
  void Update(){
   transform.position = target.position; 
   transform.Translate(diameter,0,0);
   transform.Rotate(0,0,RotateSpeed);
  }
Show more comments

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

when trying to rotate, the object transforming itself 0 Answers

How to translate an object in an unknown angle ? 1 Answer

My rotation is not the same in inspector as it is in the scirpt 0 Answers

Car Controls without physics. 1 Answer

rotate object2d the direction it is moving? 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