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 wellbranding · Feb 27, 2020 at 08:06 AM · rigidbody2dvelocityangleaxis

How to move rotated knife(RigidBody2D) diagonally?

Hello, I am new to Unity and so far enjoy my journey. Right now I have accomplished my knife constant rotation within [-30;30] degrees range. However, after the user presses any key, my knife should be moving fast in the direction it currently faces.

How can I achieve the following behavior? I tried addForce, changing velocity, but no results... Perhaps it is even impossible to do? alt text

Here my knife is facing the left angle and I would like to it to just move in that direction really fast. No fancy effects :)

alt text Here is base position

Here is my source code for the rotating knife:

 public void HandleRotation()
 {
     if (transform.rotation.z >= 0.3f)
     {
         right = false;
     }
     else if (transform.rotation.z <= -0.3f)
     {
         right = true;
     }
 
     if (right)
     {
         begin = begin + 0.05f;
     }
     else
     {
         begin = begin - 0.05f;
     }
 
     var tiltAroundZ = begin * tiltAngle;
     var target = Quaternion.Euler (0, 0, tiltAroundZ);
     transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth);
 
 }


base.png (3.8 kB)
amzz.png (4.7 kB)
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

· Add your reply
  • Sort: 
avatar image
0

Answer by tormentoarmagedoom · Feb 27, 2020 at 03:15 PM

Hello.

First, NEVER THINK THIS :Perhaps it is even impossible to do?

Second, about your problem, you have so many ways to move an object in the scene, basicly you have 2 "families" of function, the ones coming from transform, and the others coming from the Rigidbody (if exists)

I dont know whats the propouse of your knife to move so i dont know whichonce is better for your case.

As you are still "noobie" I recommend you to spend some hours reading/watching manuals/tutorials about this: (Dont try to go fast and find the solution to your only problem. A lot of things you dont even know they exists can be shown to you and give solutions you never imagined. Take your time)

https://docs.unity3d.com/ScriptReference/Transform-position.html https://docs.unity3d.com/ScriptReference/Transform.Translate.html https://docs.unity3d.com/ScriptReference/MonoBehaviour.StartCoroutine.html https://answers.unity.com/questions/1004821/what-are-ienumerator-and-coroutine.html https://docs.unity3d.com/ScriptReference/Rigidbody-velocity.html

Good luck!

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 tormentoarmagedoom · Feb 27, 2020 at 03:17 PM 0
Share

Also thisones: https://docs.unity3d.com/$$anonymous$$anual/CollidersOverview.html

https://docs.unity3d.com/ScriptReference/Collision.html

https://answers.unity.com/questions/55179/cheapest-way-to-catch-collisions-on-very-fast-movi.html

avatar image wellbranding · Feb 27, 2020 at 03:52 PM 0
Share

Actually it does not matter in my case if it will come from rigidBody or transform. I have attached rigidbody, too. What I care most about is to actually move object to the diagonal direction. I have looked at most of your provided links and have not found any way to move object diagonally, keeping knife end direction.

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

200 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

Related Questions

Terminal velocity on x and y axis is higher than normal when force is applied to both axis simultaneously. 0 Answers

Instantiate GameObject with Velocity 1 Answer

WHY IK affects Rigidbody???? 0 Answers

How to specify a maximum height velocity for rigidbody game object 0 Answers

Making Hanzo’s Scatter Arrow in 2D 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