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 unitedone3D · Oct 16, 2020 at 07:02 AM · physics.raycast

Raycast/collision driving me insane - (never works correctly, any idea?)

Hi there!

I am facing a problem of raycast not working/behaving...in the game I am making (a FPS) when the weapon is fired (like a gun), the raycast are correctly sent out, but they do not seem to work 1/2 the time, with the collision, like when a ray is sent out (when you fire the weapon) and it should 'contact' on the ennemy; the ennemy should show a pain animation; and that is what happens when I use the melee weapon 'upclose'; but even there it work 1/2 the time, like the melee weapon connects, but only like in the middle of torso or something (like it seems the raycast 'gets it/collision body gets it' around the middle of the torso as if the middle collision is big enough to read raycast (The large circle around torso), it makes the pain animation 'sometimes' work...so it's really bizarre...like tehre is a problem of collision somehow;/either the raycast is not 'felt' by the collision boxes on the skeletel mesh of the ennemy...or I don't know.

Or maybe, the collision itself just not 'read' the raycast... also, I saw that if I would press the mouse button and not release it - then many raycast are sent out 'automatic machinegun style' and then the raycast 'finally' 'are felt' by the ennemy and he does the pain animation repeatedly...I did not press the mouse button several times...just holding it send non-stop raycast...that's bizar, I only wish to send 1 raycast not an automatic stream of them...it makes weird because the animation does not match, like the gun could be reloading or doing soemthing else, and teh raycast are sent out/doing damage (while reloading animation still playing) so it's off/timing is wrong. How do we make a raycast to fire once not a continuous firing-upon holding mouse button. Anyways I know this is complicated to untangle, I'm just wondering what does devs do to make the darn collision/raycast work/behave correctly instead of never working or 'sometimes' 'when it feels like it'...I just don't get it, most liklely a very advanced coding problem. I don't think it is a bug (though I could be wrong and indeed it is).

The ennemy has capsule colliders for each large member (like capsule for torso, capsule for forearm..etc, whole body) these capsules have a logic script that 'detects collision' (when firing the weapon/raycast), but therein the problem, the raycast never works right/or at all when firing a weapon or using a melee upclose weapon. It's like the body collision capsules are just not 'reading' the raycast right when colliding on body capsule...I wonder how big/how large they are suppose to be so that the 'raycast collides - the 1st time, each time' on the body capsules. I have tested the raycast on another non-ennemy/like a box crate, and the raycast is read correctly, like the collision box on the crate, reads the raycast right and the crate is broken after firing a few times on it - so it does work but not on the ennemy/I am guessing moving skeletal collision capsule is cause of problem...would buying a 'skinned mesh collider' asset solve this (the asset that makes the entire skinned mesh - be a 'animated' skinnedcollider itself). There is one large AI logic script for the ennemy and the script is put as 'collision' on the capsules so that the ennemy 'reacts' when shot at/pain anim (the collision check is that the script is on each capsule collider of the body - put as 'collision' so that it reads raycast). While the gun/melee weapons have a shooting script (gun/melee) to 'send out' raycast each time firing to 'do damage/health point loss' on the ennemy). Any help is greatly appreciated. Thank you.

alt text

capsulecollidersforraycastreading.jpg (134.3 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

135 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

Related Questions

Physics.Raycast lagging behind 1 Answer

Single raycast from player that I can use in all other scripts? 1 Answer

event triggered by the wrong camera 0 Answers

execution order of Destroy and Physisc.Raycast 1 Answer

Bouncing ball never becomes stationary 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