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 Ilias · Mar 24, 2011 at 09:44 PM · enemyshoot

Enemy needs to shoot precisely at player

I'm using the FPS Tutorial and now i have a problem with it. The enemy didn't shoot precisely. One of the 10 bullet hits me, also if i stand at one place, it can't hit me. Is there someone can help this and tell me how to fix it. Because the mention of the enemy is that he is killing you, but if one of his bullets is hit me, it has no function.

Please help, IT'S A SERIOUS PROBLEM...

Comment
Add comment · Show 5
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 Uriel_96 · Mar 24, 2011 at 10:00 PM 0
Share

I think something you can do(if you don't) is to put a force in the bullet and make the rigid-body in kinematic so it doesn't moves

avatar image Statement · Mar 24, 2011 at 10:31 PM 0
Share

@Uriel: You are not making much sense. $$anonymous$$ake the bullet kinematic so it doesn't move, and then apply force (that still doesn't move it)?

avatar image Ilias · Mar 24, 2011 at 10:32 PM 0
Share

Thnx for the reaction, but i forgot to tell you that i'm new in unity and i'm discovering a little. So can you tell me in detail maybe how to do?

avatar image Ilias · Mar 24, 2011 at 10:34 PM 0
Share

I'm using the FPS Tutorial he.

avatar image Uriel_96 · Mar 24, 2011 at 10:41 PM 0
Share

I am saying to add a rigidbody(Component>Physics>rigidbody)and make it kinematic and then put a constant force (Component>Physics>constant force) and then put a force so the bullet goes forward so it doesn't goes up or down

2 Replies

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

Answer by Weitzel · Mar 24, 2011 at 10:50 PM

I just took a look at the tutorial you are talking about.

In this project, on the Robot prefab, there is a script called AI.js;

The problem lies between two things

var shoot angle = 4.0

This poses an issue. With this too small, it will shoot less often, and be much less likely to hit you if you are moving. It won't "lead" a shot.

With this too large, if it doesn't continue to turn, you will be satisfied without actually being pointed at the target.

The other thing is really the heart of the issue. If you notice, he always shoots just to your left. His rockets shoot from his right.

The rotation it is being satisfied from is his gameObject.transform to yours, when instead it needs to be from his child (rocket launcher).transform to yours. This is why it thinks it is aiming at you when it isn't.

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
1
Best Answer

Answer by efge · Mar 24, 2011 at 10:37 PM

I do not know the FPS Tutorial, but you could use this script. Assign the tag "Player" to your player object and attach this script to your bullet prefab. (The smooth value defines the duration of the "flight".)

var target : Transform; var smooth : float = 5.0;

function Start () { target = GameObject.FindWithTag("Player").transform; }

function Update () { transform.position = Vector3.Lerp (transform.position, target.position,Time.deltaTime * smooth); }

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

No one has followed this question yet.

Related Questions

How to reach multiple GameObjects' value , enemy AI 1 Answer

make Enemy shoot at player 2 Answers

Enemys following and shooting 1 Answer

How to stop enemies from shooting each other 1 Answer

Make enemy more intelligent 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