• 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 hoffmanuel · Sep 12, 2012 at 09:53 PM · c#rigidbodyflightrealistic

How to create a realistic flying clay pigeon

Hi!

I would need some script or logic for letting clay pigeons fly for a targeter game. The pigeons shall start form two fixed points, which one is decided randomly. The pigeons shall vary in their start direction and strength, the height is always the same. The pigeons are rigidbodies. Right now i am starting the piegeons like this:

 float randomXValue = Random.Range(-2, 2);
 float randomZValue = Random.Range(1.5f, 4);
 rigidbody.AddForce(randomXValue, 2, randomZValue, ForceMode.Impulse);

The problem is now, that the flight curve doesn't look like a pigeon you know from movies. The rigidbody is set as follows:

 mass = 0.175
 drag = 0.7
 angular drag = 0.05
 uses gravity
 collision is cont. dynamic
 no constraints

Maybe someone of you knows a way to do a realistic flight behaviour for a clay pigeon.

br hoffmanuel

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Riiich · Sep 16, 2018 at 09:06 PM

This is a script I created from your example:

 using UnityEngine;
 
 public class ClaySpawner : MonoBehaviour {
 
     public GameObject clay;
     public float nextSpawn = 3f;
     public bool secondClay = false;
 
     void Update () {
         nextSpawn -= Time.deltaTime;
         if (nextSpawn <= 0)
         {
             SpawnClay ();
         }
     }
 
     void SpawnClay ()
     {
         if (secondClay)
         {
             nextSpawn = Random.Range(3f, 7f);
             secondClay = false;
         } else {
             nextSpawn = 0.1f;
             secondClay = true;
         }
         
         GameObject tempClay = Instantiate(clay, new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z), new Quaternion(0, 0, 0, 0), this.transform.parent);
 
         float randomXValue = Random.Range(-2, 2);
         float randomZValue = Random.Range(1.5f, 4);
         tempClay.GetComponent<Rigidbody>().AddForce(randomXValue, 4, randomZValue, ForceMode.Impulse);
     }
 }

With the values Rigidbody


rigidbody.png (8.3 kB)
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

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Instantiating two rigidbody at a time 0 Answers

In need of help with OnTriggerEnter 0 Answers

Collision on character controller (fps player) 2 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