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 laszlar · May 10, 2016 at 07:49 PM · animation2d gameinfinite runner

Using direction/angle to change animation?

This is for a 2D infinte runner - I asked a previous question, but thought about it some more and have come up with a fairly vague answer that I'm not too sure about. I have a player (see diagram) that when he jumps he might miss the obstacle and play his animation regardless (which is what I don't want).

alt text

So what I was thinking - what if I had a raycast pointing toward his nearest obstacle, retrieving that angle (or mathematical function), and if it's within a threshold of whatever angle I set it will play a specific animation. This way it might not play the animation if he will miss the obstacle. Is something like this possible? Or is there something easier?

Some additional info - player's x and z values are frozen (he only jumps). Obstacles constantly fly at him.

collisionissue.png (11.0 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 Nazirzadeh · May 10, 2016 at 08:01 PM

Check collision for your obstacle, if it is collided then play your specific animation, also you can put your obstacle inside an invisible box collider , then you can define boundary for your collision and check the collision in that boundary.

Comment
Add comment · Show 8 · 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 laszlar · May 10, 2016 at 08:52 PM 0
Share

@$$anonymous$$J$$anonymous$$C this is what I have above. Boundary? Having a boundary is essentially redundant if I already have a collider isn't it?

avatar image Nazirzadeh laszlar · May 11, 2016 at 05:01 AM 0
Share

You do not want to miss the obstacle, am I right? Suppose that player jumps over the obstacle and pass it without any collision. How do you want to notice that?

I think your boundary should be a little bigger than your obstacle, which your player cant jump over it. Not too much big.

It seems you already have a Trigger collider. Does it work at all?

I am using boundaries for playing animations like yours and it works perfectly, I check OnTriggerEnter() function to notice the overlap with boundaries.

avatar image laszlar Nazirzadeh · May 11, 2016 at 01:16 PM 0
Share

@$$anonymous$$J$$anonymous$$C There might be some solution...Yes - I have a trigger on it, and it does its job. It works perfectly, but then it plays again, or it's delayed. I think what the problem is is that OnTriggerEnter2D might not be the best solution (nor OnTriggerExit), because I want him to play the animation while hitting the object, and not playing the animation while missing the object. I would have to post a gif or video to better describe this situation, and I might just post it on the forums side.

Show more comments

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

83 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

Related Questions

Changing sprites with animations 0 Answers

How to handle Instantiation and Destroying on an infinite runner? 1 Answer

my attack animation is not working 3 Answers

Player not being rendered until input has been detected. 1 Answer

How can I fix my animation? 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