Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Parent rotation to control child trajectory rotation.

Discussion in 'Scripting' started by Overunity3d, Aug 14, 2011.

?

Is this trajectory a force application?

  1. Necessary

    100.0%
  2. Unnecessary

    0 vote(s)
    0.0%
  1. Overunity3d

    Overunity3d

    Joined:
    Sep 5, 2010
    Posts:
    14
    I fire a tumbling sphere-child in a rotating environment. The sphere-child trajectory does not rotate although the sphere-child position adjusts within the rotating parent. The trajectory keeps going in the initial direction. I have tried constantforce, add force even relative options to no avail. Does anybody have a clue? I have spent a month on this. Do I need to calculate something instead of relying on the unity physics engine? Thanks for any direction.
    I mentioned tumbling because I can not rely on a single axis. I also can not , over time, use the parent's direction because the child bounces off the parents walls to create another trajectory / path direction.

    My spawnpoint, for instantiation sits outside the rotating parent and is a child of the main camera. The trajectory starts off with the forward direction of the spawnpoint. The instantiated child is then reparented with the rotating parent.

    Here is where the problem shows up:
    The child direction / trajectory / path of travel by force never changes from the original forward force.
    If I use Fixedupdate the trajectory path correction is so slow that the child's path spirals as each axis is used to get a force in it. But then there is a slight rotation to the trajectory. I don't know if this is correct.

    Code (csharp):
    1. var Opponentshoot = Instantiate(Opponentshoot,  GameObject.Find("SpawnPoint").transform.position,  GameObject.Find("SpawnPoint").transform.rotation);
    2.     Opponentshoot.transform.parent = GameObject.Find("GameObject").transform; //This enables the child to rotate with parent!!!
    3. var Opponenttest = GameObject.FindWithTag("Opponent").transform;
    4.     //var Opponenttest = GameObject.FindWithTag("Opponent").transform;
    5.     //Opponenttest.rigidbody.AddForce(transform.forward * 50000); //This produces force in local forward, cannot use tumbling vectors for trajectory
    6.     Opponenttest.constantForce.force = Vector3.forward * 5000;
    7.  
    Am I seriously missing something in my analysis of what I am to do in Unity3d?

    Another good example is a pool table. If I spin the table on the Y axis as the balls are moving they should not deviate on the travel path but follow the table and not the viewer. This would constitute a straight path and not a curved path. As can be seen in this example the ball could be rolling on an axis that does not wobble. This would a constant force. Regardless of the image on the ball wobbling the ball moves forward. When the ball hits a rail a new forward angle is set. This new forward direction has nothing to do with local axis. Right?
    Another example is the Atari asteroids game. Except in my case the universe can spin in front of the viewer. Do the asteroids change course? Of course not but to the viewer the direction changes.

    In FixedUpdate() I do not have a static axis to apply force on. As the sphere tumbles the local axis rotate in all angles. Will world axis adjustment solve this problem?

    In the Unity3d community I see all kinds of answers but nothing addresses this complexity or so I think. Am I looking at this incorrectly or is the a bug in Unity?
     
    Last edited: Aug 18, 2011
unityunity