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
1
Question by stingman · Apr 04, 2012 at 09:43 PM · physicsrigidbodyenemyprojectileslerp

Projectile Boomerang

Anyone got any good ideas for a projectile to have a boomerang effect? I've thought of creating an empty game object with a box collider attached and when the projectile collides with the empty game object it will return back to its instantiated position and then disappear. But then I have to calculate arc too... seems like the physics could present some problems for me as it's not a strong point of mine. Regardless maybe someone has some suggestions or has done something similar to this? Thanks for any tips or suggestions!

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

Answer by cregox · Apr 04, 2012 at 10:33 PM

Supposing all you want is the projectile to blindly follow a boomerang-like-path, you can simply set the math for an ellipsoid interpolation under Update. Here I modified the example on Slerp (even though I don't quite understand it myself). It's only half the path, but it works just with copy and paste:

 using UnityEngine;
 using System.Collections;
 
 public class BoomerangEffect : MonoBehaviour {
     public float duration = 1; // in seconds
     
     public Vector3 beginPoint = new Vector3(0, 0, 0);
     public Vector3 finalPoint = new Vector3(0, 0, 30);
     public Vector3 farPoint = new Vector3(0, 0, 0);
     
     public bool startAgain = false;
     
     private float startTime;
     
     void Start () {
         startTime = Time.time;
     }
     
     void Update () {
         if (startAgain) Start();
         
         Vector3 center = (beginPoint + finalPoint) * 0.5F;
         center -= farPoint;
         
         Vector3 riseRelCenter = beginPoint - center;
         Vector3 setRelCenter = finalPoint - center;
         
         transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, (Time.time - startTime) / duration);
         transform.position += center;
     }
 }

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
avatar image
0

Answer by stingman · Apr 05, 2012 at 01:15 AM

Thanks for the tip. I was actually looking at the Slerp example too and studying the physics of boomerangs and got stuck trying to find a way to convert the equations to code. this will definately help tho appreciate it :) on a side note... i found a very easy way to make this work. I animated the projectile's path in a 3d modeling program and instantiate the object and it's associated animation at the release point for the weapon. I attached a box collider to the boomerang and just wrote a script that if my player collides with it then the death sequence will start. haha... i know it's a cheap way of making it work.. but i've done that for now :) regardless appreciate this code... will definately look into it

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Shooting a cannonball. 6 Answers

Projectile collides, freezes, but flips to weird angle. Help! 0 Answers

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

How to stop an rigidbody enemy from jumping when chasing the player? 1 Answer

Adding player velocity to projectile not working 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