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 /
  • Help Room /
avatar image
0
Question by kmay11005 · Sep 08, 2020 at 08:23 PM · missilehoming

Homing missile just rolls toward the player/not floating

I'm using this script for a homing missile that I got off of a tutorial. The homing part is fine but when the player is on the ground, the missile object is on the ground and looks like it's rolling toward the player. Is there a way to get the missile to float until it is a certain distance from the player? The ground is a flat plane with a few walls here and there that destroy the rocket upon collision.

public class Track_Player : MonoBehaviour { public Rigidbody rb; public Transform player; public float turn; public float speed;

 // Update is called once per frame
 void Update()
 {
     rb.velocity = transform.forward * speed;
     var missileRotation = Quaternion.LookRotation(player.position - transform.position);
     rb.MoveRotation(Quaternion.RotateTowards(transform.rotation, missileRotation, turn));
 }

}

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by judahcline · Sep 10, 2020 at 01:34 PM

your rigidbody might still have gravity on it so change that number to 0. but if it already at zero you can add a raycast to check if it is to close to the ground

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 kmay11005 · Sep 10, 2020 at 03:50 PM

@judahcline

What do you mean change the gravity number to 0? Do you mean turn gravity off or is there a function/option that I don't know of that strengthens gravity?

Comment
Add comment · Show 3 · 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 Mazer83 · Sep 15, 2020 at 06:37 PM 0
Share

What they mean is: Look at the RigidBody of the missile object, it should have a property called: "Gravity Scale". If it's set to 0, it won't be affected by gravity. You can change this at run time.

Can you specify a bit more what it is that you're trying to do? Do you want the missile to try to avoid hitting the ground? Do you want it to explode instead of rolling when it does hit the ground? Both?

avatar image kmay11005 Mazer83 · Sep 16, 2020 at 05:05 AM 0
Share

@$$anonymous$$azer83 I looked through the rigid body and did some research online, but unity 3d doesn't have a gravity scale setting, instead, it has a use gravity settings. Switching to disable gravity does make the missile hover over the ground a little though.

avatar image kmay11005 Mazer83 · Sep 16, 2020 at 05:33 AM 0
Share

Eventually, I want the missile to do both. When I ran the game, unless the player object was jumping, the missile was on the ground, and it looked like it was rolling toward the player. So I've been trying to get the missile object to track the player whilst hovering over the ground at a certain height until it's a certain distance from the player, which at that point, I wanted it to descend/dive toward the player. But now that I actually got the missile to float, the descend/ dive part seems like a bad idea. I might still want the missile to hover a little bit higher than it is now, but not really sure how to do that so any help is appreciated.

I'm planning to add the explosion upon collision, and avoiding hitting the ground stuff once I figure out the ho$$anonymous$$g parts out by using raycasts, capsule checks, and Addforce.

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

209 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

Related Questions

Trying to get missile to home in on player position instead of one fixed position 0 Answers

How do I complete homing missile movement? 0 Answers

Homing Missiles! 1 Answer

Missile Boucne Issues (need a creative solution) 0 Answers

Missile Won't Attach as a Child of an Airplane. Why? 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