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 jeffreyf · Oct 21, 2012 at 10:21 PM · rigidbodyprojectilecharacter movement

Instantiating projectile object is affecting the movement of instantiater

Hello. I'm trying to create a game where your character's movement is based on where you are shooting. So if you shoot down, it'll essentially be like jumping. I have two guns, so you can be shooting downwards with both to speed up your ascent.

I'm having a bit of trouble with the creation of the projectile. When I add the impulse to the character without creating a "Shot" prefab, my character moves as expected (smoothly moving upwards when both guns are shooting downwards or slightly to the side). However when I create the projectile, sometimes it seems the character gets stuck or something on the prefab, causing the movement to be jerky and unsmooth.

I've tried playing around with my "Shot" prefab, removing its rigidbody and collider and such. It seems that when the collider is not active, this problem doesn't exist and the character can move smoothly. However I am going to need that collider to perform other checks.

Another thing I am doing is calling Physics.IgnoreCollision. This seemed to work in terms of my projectile not getting destroyed when it hits the character, but the jerkyness still exists. Here's my code for that call:

     GameObject shot = Instantiate(projectile, hand.position, hand.rotation) as GameObject;
             
     Collider colliderBody = transform.parent.GetComponentInChildren<BoxCollider>() as Collider;
     Physics.IgnoreCollision(colliderBody, shot.collider);
             
     shot.SendMessage("SetVelocity", -firePower * firePower * lastRotation);

I am thinking maybe there's another rigidbody it's getting stuck on within my character, but I don't have any colliders or rigidbodies attached to it besides the one that it'd find with GetComponentInChildren BoxCollider(). Any suggetsions on what I can do to fix this jerkiness?

Comment
Add comment · Show 3
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 Fattie · Oct 22, 2012 at 07:42 AM 0
Share

u need to learn about LAYERS in unity physics, it's a basic of video games.

here's the full explan

http://docs.unity3d.com/Documentation/Components/LayerBasedCollision.html

enjoy!

avatar image jeffreyf · Oct 22, 2012 at 01:39 PM 0
Share

@Fattie: Thanks for the link! So I added a projectile layer to my Shot prefab, and a Player layer for my player (I added it to the parent Player object, it asked if I wanted to apply to all children, I said yes please). In that layer matrix under physics I have it so projectiles and players won't collide with one another. Yet I am still getting this jerky motion! I do not understand what's going on, this bug has been bugging for 3 weeks now :@

I've also tried instantiating the object far away, setting ignorecollisions and then moving the object back. Still collides with my player, messing up his motion (sometimes the player will lose all momentum, and it looks really jerky).

avatar image jeffreyf · Oct 22, 2012 at 02:08 PM 0
Share

http://answers.unity3d.com/questions/13659/how-to-ensure-projectiles-dont-bump-into-each-othe.html

I also tried that link, ignoring collisions in the start of the projectile. Still jerky! I have no idea what this problem could be

1 Reply

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

Answer by jeffreyf · Oct 22, 2012 at 09:53 PM

I found the problem. After spending hours looking into this, testing various physics etc, I realized that one of my scripts was doing a downwards raycast that would zero the velocity when it hits something. So stupid and frustrating!

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

10 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

Related Questions

How to calculate projectile (baseball) distance with drag factor 1 Answer

Controll 3D Rigidbody Projectile with Joystick 1 Answer

Very intermittent Collsion with grenade projectile and room with mesh collider. 1 Answer

Dart projectile collide with another dart in the board 0 Answers

Rigidbody Controller Jittery 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