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 zr0 · Oct 28, 2012 at 04:05 AM · vector3gun

help with vector3

I am trying to simulate bullet drop over time using vector3, I have already got bullet time but I get errors trying the bullet drop. what I am asking is can you or how do you make impactpos(Vector3) the hit point and times the Y axis by -bulletdrop?

 function fire () {
 //setting the var fwd2 to the foward position
 var fwd2 = transform.TransformDirection(Vector3.forward);
 //hit variable 
  var hit2 : RaycastHit;
  //ray variable 
  var ray2 = new Ray (transform.position, transform.forward);
  //detecting if there is a collition 
 if (Physics.Raycast (ray2, hit2, 100000)){
 //making smoke from the barrel
 Instantiate(smoke,transform.position,transform.rotation);
 //setting the bullet time to 0.003 * the distance 
 bullettime = hit2.distance * bulletinterval;
 //pointofhit = hit2.point; - trying other ways to get it to work 
 //get the bullet drop, drop * 0.003 or something as small 
 bulletdrop = hit2.distance * bulletdropamount;
 //the single line that does not work - just trying to set the variable 
 //impactpos to hit2.point with extended vector3 so i can subtract the bullet drop 
 impactpos = hit2.point(Vector3(hit2.point.x, hit2.point.y, hit2.point.z));
 // waiting for the time of the bullet to reach the target
 yield WaitForSeconds(bullettime);
 //creating the inpact for the explotion or other sparks 
 Instantiate(impact, impactpos, transform.rotation);
 
 } else { 
 // makeing smoke even though that there is no target in sight to simulate a miss
 Instantiate(smoke,transform.position,transform.rotation);
 }
 
 }

   


the error i am getting from unity is "It is not possible to invoke an expression of type 'unityEngine.Vector3'"

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 electricsauce · Oct 28, 2012 at 04:38 AM 0
Share

What errors are you getting?

avatar image zr0 · Oct 29, 2012 at 03:38 AM 0
Share

"It is not possible to invoke an expression of type 'unityEngine.Vector3'"

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Jessespike · Oct 28, 2012 at 08:28 AM

impactpos = bulletpos(Vector3(hit2.point.x, hit2.point.y - (bulletdrop * bullettime), hit2.point.z));

Not tested, and the vars probably need to be swapped or using different signs. But basically you can calculate how much the bullet has dropped (gravity) by multiplying bulletdrop and bullettime. In this case, DropAmount = HowLongBulletHasBeenInAir * StrengthOfGravity; Then you subtract that from the y position of the impactpos.

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 zr0 · Oct 28, 2012 at 10:17 AM 0
Share

I get an error "It is not possible to invoke an expression of type 'unityEngine.Vector3'"

avatar image
0

Answer by zr0 · Oct 29, 2012 at 05:47 AM

it is all g i got the answer

 impactpos = Vector3(hit2.point.x, hit2.point.y - bulletdrop, hit2.point.z);
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

11 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

Related Questions

Aim Down Sights Positioning Problem 1 Answer

bullet doesn't go anywhere 1 Answer

Setting Without Altering Object Scale and Collider Scale 0 Answers

Gaussian Distribution in circle on x and y axis 1 Answer

Aim Down Sights and Weapon Sway not working unless animations are not assigned 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