Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed Jan 20, 2018 at 09:07 AM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Thilinkalin · Jan 18, 2018 at 04:45 AM · unity 5unity5dragoncollisionenteroncollisionexit

**Trying to make a shield that slows downs bullets when bulletes enter**

Bullet tag: Bullet and shield tag: BulletTimeShield

hey i have tryed so many things and i really need help!

like i said at the top im trying to make a shield that slows the bulletes as they are going in and speeds up to normal speed when they exit

i have tried rigidbody drag and Oncollisionenter and exit but thats not working

i really hope that some one can help me

thanks for reading and your time

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 Ginxx009 · Jan 18, 2018 at 05:27 AM 0
Share

So it's like when you activate your shield the bullets will reduce its speed . Is that what you meant. I'm just clarifying things.

avatar image Thilinkalin Ginxx009 · Jan 18, 2018 at 10:10 PM 0
Share

more when i Activate it and a bullet flys in to it :) ps its a 3d game :)

B = Bullet

( ) <----B Bullet normal speed ( B ) Slow bullet <-----B ( ) Normal Speed :P

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by meat5000 · Jan 19, 2018 at 02:00 PM

OnCollisionEnter, access via GetComponent the rigidbody of the object. Store the current velocity value. Reduce it by percentage or fraction and restore it OnCollisionExit

This may not work as expected due to discrepencies in the Collision Detection of fast moving objects.

However, as you imply the object should move through, you will probably need to use OnTrigger functions instead.


Edit : Ok, on large objects it seems that this approach only works while planes are intersecting. However, this following method will work but may be a little intensive. Its a little rough and has drawbacks specifically with multiple objects, but its for the illustration of a working method.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class SlowObject : MonoBehaviour {
 
     Vector3 tempTriggerVelocity;
     Rigidbody otherRB;
     float scaler = 0.1f;
     
     void OnTriggerEnter(Collider other)
     {
         otherRB = other.gameObject.GetComponent<Rigidbody>();
         tempTriggerVelocity = otherRB.velocity;
     }
     
     void OnTriggerStay(Collider other)
     {
         otherRB.velocity = tempTriggerVelocity * scaler;
     }
     
     void OnTriggerExit(Collider other)
     {
         other.gameObject.GetComponent<Rigidbody>().velocity = tempTriggerVelocity;
     }
 }
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 Thilinkalin · Jan 19, 2018 at 05:11 PM 0
Share

aah thank you so much! :P i did the trick! :P i totaly forgot about ontrigger event :)

avatar image
1

Answer by Husnain_ · Jan 18, 2018 at 05:14 AM

make a gameObject i.eBulletSpeedHandler that handle all bullet speed. make a static float speed variable here so that every bullet can get speed from here. and make sure u are using speed like this

transfrom.translate(BulletSpeedHandler.speed*vector2.whateverDirection)

now in the shield you need to reduce/increase the value of speed simply ,sdsf

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 Thilinkalin · Jan 18, 2018 at 05:42 PM 0
Share

so if its a 3d game i can do

transfrom.translate(BulletSpeedHandler.speed*vector3.Forward)??

Follow this Question

Answers Answers and Comments

155 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 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

How can I make a collider that gives me stat up to stop giving me it? 0 Answers

OnCollisionEnter Problem 1 Answer

How do I rotate the player to the facing direction as in here? The camera follows it so I want to move it to facing direction. 1 Answer

Drawing a GUI line 0 Answers

void OnTriggerExit 3d not working on my script? 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