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 /
avatar image
0
Question by Mythran · Feb 26, 2017 at 12:56 PM · rotationmovementtransformorientation

The way to approach DodgeRoll

The player moves towards the key directions wherever is targeting the enemy or not. The only diference is that when targeting the player is always facing the enemy.

The intention is when targeting, if the player dodge to the left or right he dodge 4meters around the target and forward or back 4 meters in the direction of the target or away.

This is how far i got..

//Dodge Forward if (Input.GetButtonDown("Vertical") && Input.GetAxis("Vertical") > 0 && (playerController.collisionFlags & CollisionFlags.Below) != 0 && Input.GetAxis("Horizontal") == 0) { if (Input.GetButtonDown("Vertical") && (Time.time - lastTime) < 0.5f && Input.GetButtonDown("Vertical") && (Time.time - lastTime) > 0.1f && Input.GetAxis("Vertical") > 0.03f) { lastTime = Time.time;

                     if (isTargetLocked) {
                         //direction = Vector3.forward;
                         direction = (target.transform.position - playerController.transform.position).normalized;
                         destinationDistance = (playerController.transform.position) + direction * 4;
                         StartCoroutine(TargetDodgeRoll());
                     }
                     if (!isTargetLocked) {
                         destinationDistance = playerController.transform.position + Vector3.forward * 4;
                         StartCoroutine(DodgeRoll());
                     }
                     Debug.DrawLine(playerController.transform.position, destinationDistance, Color.red, 10f);
                     //destinationDistance = playerController.transform.position + new Vector3(0f, 0f, 4f);
                     StartCoroutine(DodgeRoll());
                     isDodging = false;
                 } else
                     lastTime = Time.time;
             }

public IEnumerator TargetDodgeRoll() {

         while (!Mathf.Approximately((playerController.transform.position - destinationDistance).sqrMagnitude, 0)) {
         
             isDodging = true;
 
             if (!isDestination && isTargetLocked == true) {
 
                 Quaternion targetRotation = Quaternion.LookRotation(target.transform.position - playerController.transform.position);
                 transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, turnSmoothing * Time.deltaTime);
                 playerController.transform.position = Vector3.MoveTowards((playerController.transform.forward), destinationDistance, dodgeSpeed * Time.deltaTime);
                 Debug.Log("Destination: " + !Mathf.Approximately((playerController.transform.position - destinationDistance).sqrMagnitude, 0));
                 yield return null;
 
             } else {
 
                 yield return null;
             }
         }

The distinationDistance is correct but the direction the player goes is wrong. Also i couldn't figure out how to move around the target 4 meters at fixed orbit.

Thank you

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 Mythran · Feb 27, 2017 at 10:29 PM 0
Share

5 days many trignometry but problem solved!

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Rotatating a character 2 Answers

Make an object move to a given point by rotating to the correct direction first. 1 Answer

Character rotation and move to mouse click point with speed 0 Answers

How can I get my model to face the direction it is moving? 2 Answers

transform.Translate but Transform has Rotation!=0 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