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 Sergey · Aug 23, 2010 at 10:40 PM · jumpattackhoming

How to make a Homing Attack like in Sonic the HedgeHog?

Hi! I am making a Sonic game, and I want to make a Homing Attack special ability. Could anyone help me?

Description of Homing Attack: when Sonic is jumping (or descending) and if any enemies or objects are close Sonic can aim at them and fly in their direction. After striking an enemy or object, he is knocked back up into the air and can do another Homing Attack. If there are no enemies and objects around Sonic, he can only do a Jump Dash forward. I hope, somebody will understand my not-so-good English and help me...

Comment
Add comment · Show 2
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 Peter G · Aug 23, 2010 at 11:49 PM 0
Share

I fixed your English. It wasn't that bad. There were only one or two mistakes. :)

avatar image Sergey · Aug 24, 2010 at 10:12 AM 0
Share

thank you..:)))

2 Replies

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

Answer by skovacs1 · Aug 24, 2010 at 05:16 AM

This is not a good question - too unspecific and open for debate. People are not here to write your game for you.

One way to do it:

  • Tag your homing targets appropriately
  • In a script somewhere, store a public array of Transforms.
  • Have a sphere or other collider attached to your character. Set it as a trigger.
  • To this collider object, attach a script with OnTriggerEnter which adds the target's transform to the public array, checking their tag and OnTriggerExit which adds the target's transform to the array, checking their tag.
  • In the spawn scripts that create targets, check if they are inside the trigger and them to the array.
  • If the target destruction scripts doesn't destroy() them, be sure that they are removed from the array.
  • In the script with the array, in an Update function check if the character is in the air and if the homing attack button is pressed and if the array is nonempty, set the character's target to be the transform position of the nearest target in the array and set a flag to jump attack (you can store specific jump attack target transforms if you like).
  • In the script that moves the character, check the flag for the jump attack and if it is set, move the character towards the target in stead of normal movement controls.
  • In the a script on the character, include in the OnCollision a check for a homing attack flag. If the flag is set, unset the flag, perform damage calculation and perform a jump the same as you would on the ground.

In stead of using a trigger area and a public list, you could instead check against every single enemy's transform.position and check the distance squared to your character's position. If they are within a certain range, add them to a list local to the Update function.

In stead of the OnCollision to do the damage and jump, you could alternatively check if the positions are equal.

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
0

Answer by EstebanFernandez · Jun 29, 2020 at 03:50 PM

I need the script im stuck in my game :c

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

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

1 Person is following this question.

avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

2.5D Platformer - Jump Question 1 Answer

c#help reversing a script 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Jump, fall, and after determined time it's able to jump again. 2 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