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 KuPAfoo · Dec 15, 2013 at 10:53 PM · rotationattacking

Spinning attack!

So, I've created an animation of my character putting his sword straight out. Now, I want to spin the character until the player releases the button... The position should be reset when the button is let go (getkeyup(keycode.alpha1) would be used here. The question is, how can i record all the player stats before I go into the rotation and also how Will I rotate the player? I just finished solving a huge problem and tbh am a little lazy to look in this moment. Of course, as always if nobody wishes to respond i'll keep digging.

 if(Input.GetKey(KeyCode.Alpha1))
         {
         Debug.Log ("Should Be Skill Attacking");    
             animation.Play ("skillAttack");
             
         }
Comment
Add comment · Show 1
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 KuPAfoo · Dec 21, 2013 at 06:01 AM 0
Share

I am having no luck... The below script does nothing.

 void Update () {
         if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Alpha1))
             constantForce.relativeTorque = Vector3.right * 2;
             //transform.Rotate(Vector3.right, constantForce.relativeTorque * Time.deltaTime);
     //        transform.rotation = Quaternion.Euler ( transform.rotation.x++, transform.rotation.y, transform.rotation.z );
     }

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by KuPAfoo · Dec 21, 2013 at 09:37 PM

The solution:

 if(Input.GetKey(KeyCode.Alpha1)){
                 
             transform.Rotate (Vector3.up, speed * Time.deltaTime);
                 if(speed<4000)
                 speed+=1.0f;
             }
             
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 Benproductions1 · Dec 21, 2013 at 09:04 AM

Hello,

The character rotation should probably be an animation, not something you calculate at runtime, while keeping track of the position is easy:

 //UnityScipt
 
 private var attackStartPosition:Vector3;
 
 function StartAttack() {
     attackStartPosition = transform.position;
 }
 
 function StopAttack() {
     transform.position = attackStartPosition;
 }
 
 //C#
 
 Vector3 attackStartPosition;
 
 public void StartAttack() {
     attackStartPosition = transform.position;
 }
 
 public void StopAttack() {
     transform.position = attackStartPosition;
 }

Hope this helps,
Benproductions1

Comment
Add comment · Show 1 · 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 KuPAfoo · Dec 21, 2013 at 09:25 PM 0
Share

Hmm... I was trying to animate the rotation in blender but it wouldn't rotate properly.. It would rotate clockwise 12o'clock, 6 o'clock, counterclockwise 12 o'clock. Even if it was animated as 12 o'clock 3 o'clock 6 o'clock when trying to animate to 9 o'clock it would counter-rotate back past 3o'clock into 12 o'clock then 9 o'clock...

The above reelwirax's suggestion is kind-of panning out... I had to find the proper file that was constantly setting the player's rotation. Now that i've located it, I've found that this rotates the player forward:

  if (IsGrounded())
         {
             if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.Alpha1))
             transform.Rotate (Vector3.right, speed * Time.deltaTime);
             else
             transform.rotation = Quaternion.LookRotation(moveDirection);
 
         }
avatar image
0

Answer by reefwirrax · Dec 16, 2013 at 01:54 AM

// Rotates the object around the its own x-axis

 constantForce.relativeTorque = Vector3.right * 2;
Comment
Add comment · Show 4 · 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 KuPAfoo · Dec 16, 2013 at 02:22 AM 0
Share

I'm running into errors that brought me to documentation saying use "addForce" and that makes a certain child object move, not rotate :\

avatar image KuPAfoo · Dec 16, 2013 at 02:45 AM 0
Share

This appears to be working the best, however it only points my character to the right :\

 moveDirection = Vector3.right;
avatar image KuPAfoo · Dec 21, 2013 at 03:11 AM 0
Share

there is no "Constant force" attached to the object

avatar image KuPAfoo · Dec 21, 2013 at 05:21 AM 0
Share

any help is appreciated

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

18 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

Related Questions

Flip over an object (smooth transition) 3 Answers

Rotating a 2D object when the phone is rotated 1 Answer

Character Controller slides sideways when it hits objects are angles different from 90 degrees 1 Answer

Move and Rotate object with "Parent" without Parenting 1 Answer

Rotating a rigidbody on mouse click. 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