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 oinkoinkflapflap · Dec 05, 2010 at 12:02 PM · transformfpsshootingforward

transform shooting forward

i have on my FPS transform.forward * 10000(the speed) but when i fire its always firing forward not up if im aiming up it just goes forward not up were im pointing.... please help :O

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

Answer by Proclyon · Dec 05, 2010 at 12:16 PM

To actually get a location of where to shoot you don't just give it the "forward" Vector.

Forward is always the same value. Increment along the x axis I believe, up being the Y axes and so on.

What you need is to extract the current location of what you "target" , assuming mouse by registering a position in 3D space (I assume) with for example Raycasting.

When you fire you register the input, that event triggers a script based measurement of the location. The location information is store in a Vector3 object. That information is now ready for use in determining the position between source and destination.

Source being point A and destination being point B you could do a Linear Interpolation (LERP) , or use Trigonometry to determine the forces required to get the correct angle. I am sure Unity has 89267892 functions for this of which I know zero. I usually just work with math, being all new to Unity and so. So please do look before doing that part yourself. The LERP function is part of the Mathf library I do know for a fact.

Well hope this gets the theory part covered for you. Sorry for not supplying a readily availabe answer but I don't have the time investement available for it now.

Good luck :)

Comment
Add comment · Show 2 · 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 oinkoinkflapflap · Dec 10, 2010 at 06:41 PM 0
Share

thanks 4 your help i've solved it thanks :D

avatar image Proclyon · Dec 10, 2010 at 08:10 PM 0
Share

Good to know you solved :) Don't forget to flag something as an answer if you think it is , and the opposite aswell. If something is totally not helpfull for anyone just vote down

avatar image
0

Answer by FLASHDENMARK · Dec 05, 2010 at 12:06 PM

Hmm... dont know if it helpes but try:

bullet.rigidbody.AddForce(transform.forward * 10000);

At bullet type what ever your "bulletPrefab" is called, and your bullet needs a rigidbody.

Hope that helped:)

Comment
Add comment · Show 1 · 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 oinkoinkflapflap · Dec 10, 2010 at 06:42 PM 0
Share

this is already in my script, i realized what i did wrong, it was firing the direction of the component the script was attached to not were the camera pointed, but thank you :D

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

Move an object forward and not up? 1 Answer

Rayshoot Reload Problem (Can still shoot) 2 Answers

Turn and Move Foward 1 Unit relative to Objects local direction 1 Answer

Findinga GameObject Transform 1 Answer

fps shooting enemy 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