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 Codelyy · Dec 27, 2016 at 03:40 AM · c#movementaivelocityattack

Super Sonic Movement Help

I'm trying to recreate the sonic boss fight from the game "I wanna be the boshy" just for fun and currently I'm at the stage where I'm programming super sonic and trying to program this attack: https://www.youtube.com/watch?v=h_o8AnZX9FA&feature=youtu.be&t=18s

I'm using this function that is run in the Update loop for the attack:

 public void SuperFly(float speed, float maxSpeed)
     {
         float xa = speed;
         float ya = speed;
         flyV = rig.velocity;
 
         xv = Mathf.Clamp(xv, -maxSpeed, maxSpeed);
         yv = Mathf.Clamp(yv, -maxSpeed, maxSpeed);
         flyV.x = xv;
         flyV.y = yv;
         rig.velocity = flyV;
 
         Vector2 v = rig.velocity;
          float angle = Mathf.Atan2(v.y, v.x) * Mathf.Rad2Deg;
          transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
         transform.localScale = new Vector3(1, 1, 1);
 
         if(!runningState) //Start Of State
         {
             stateTimer = 30f;
             anim.SetTrigger("SuperFly");
             transform.position = deathPoint.transform.position;
             runningState = true;
         }
 
         if (transform.position.x > player.transform.position.x)
         {
                xv -= xa;
         }
         else
         {
             xv += xa;
         }
 
         if (transform.position.y > player.transform.position.y)
         {
             yv -= ya;
         }
         else
         {
             yv += ya;
         }
     }

It seems to be very similar to the movement in the game but there is just something about it that is off and I can't tell what. It seems sonic's movements in the actual game is a lot more quick and sharp then mine are but I'm not sure how I can edit my code to make that happen. This is what the movement looks like within my game: http://i.imgur.com/742KsgR.gif

If you look at the video and my gif then you should be able to see a difference with the movement but as I said, I'm just unsure what to change. I'd love some 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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by lamphung719 · Dec 27, 2016 at 06:39 AM

maybe this can help you out?

https://s-media-cache-ak0.pinimg.com/originals/6c/1b/a4/6c1ba40bf194cd0fc99c06207246b51f.gif

Comment
Add comment · Show 7 · 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 Codelyy · Dec 27, 2016 at 05:51 PM 0
Share

How exactly would I script something like that though?

avatar image lamphung719 Codelyy · Dec 28, 2016 at 03:35 AM 0
Share

You need a little bit math for this, from the motion type, you need an equation to deter$$anonymous$$e parameters for your movement. This site maybe helps you a bit to generate the equation http://www.timotheegroleau.com/Flash/experiments/easing_function_generator.htm

avatar image Codelyy lamphung719 · Dec 28, 2016 at 08:10 PM 0
Share

Don't think I'm actually skilled enough to do that, sadly.

Show more comments
Show more comments
avatar image ericbegue Codelyy · Dec 28, 2016 at 07:50 AM 0
Share

You can also use a package that already implements all type of interpolation functions. Have a look DOTween, it's a great package for tweening (doing animation based on interpolation).

avatar image lamphung719 Codelyy · Jan 10, 2017 at 03:37 AM 0
Share

hey man, did you set up your DOTween in the editor?

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

285 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 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

Making a bubble level (not a game but work tool) 1 Answer

how to make 2D platformer AI for a skeleton 0 Answers

Acceleration problems (don't know how to make it stop moving) 0 Answers

AI Mecanim Movement help!! 1 Answer

Return Proper Velocity of Player object 3 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