Search Unity

[WIP]-shooting objects and orbit-"Lagash"

Discussion in 'Works In Progress - Archive' started by shahan, Jul 22, 2014.

  1. shahan

    shahan

    Joined:
    Jan 27, 2014
    Posts:
    25
    My WIP can be played here: http://sia.github.io/testGame/ (restart button in top left)

    I've got some of my basic ideas down. I want to finish small goals step by step.

    right now the controls are WASD and space , the mechanic is that you can hold Left Click and hold middle click to move one of the rotating objects in orbit around and away from the avatar.
    This mechanic is really really wrong right now. it just translates, stops on the plane and keeps rotating on its' axis.

    What I want is that when you left-click, the first "bullet" to detach from parent, STOP rotating and shoot out in high speed from that relative direction. (possibly later one some kind of homing missile mechanic)
    Then destroy that bullet when it gets a certain distance away. and also some trail rendering .

    Then when you click again it shoots the next one in line. I only put in the middle click hold feature to illustrate what i want as it moves the second bullet.

    Here is the script:
    Code (JavaScript):
    1. #pragma strict
    2. var speed = 2;
    3. var i = 0;
    4. var speedForChange: int;
    5. var parentOfBullets: GameObject;
    6. var bullet1 : GameObject;
    7. var allChildren = parentOfBullets.GetComponentsInChildren(Transform);
    8.  
    9. function Start () {
    10.  
    11. }
    12.  
    13. function Update () {
    14.     var rotvar = speedForChange * Time.deltaTime;
    15.  
    16.  
    17.     for (var child : Transform in allChildren) {
    18.         // do whatever with child transform here
    19.         child.transform.Rotate(Vector3.up * rotvar, Space.World);
    20.     }
    21.  
    22.         if(Input.GetMouseButton(0)){
    23.         allChildren[i].transform.parent = null;
    24.         allChildren[i].transform.Rotate(0,0,0);
    25.         allChildren[i].transform.Translate(Vector3.right * (Time.deltaTime*10), Space.World);
    26.         //allChildren[i].transform.position = transform.forward * speed * Time.deltaTime;
    27.         }
    28.         if(Input.GetMouseButton(2)){
    29.         allChildren[i+1].transform.parent = null;
    30.         allChildren[i+1].transform.Rotate(0,0,0);
    31.         allChildren[i+1].transform.Translate(Vector3.right * (Time.deltaTime*10), Space.World);
    32.         }
    33.  
    34.     }
    35.  
    I know it has something to do with the fact that it is in the looping update function and that what I want won't work. I think it keeps rotating the object.
    And I have no idea how to make the shooting part work the way I want it to. I know the code isn't right there...

    I would greatly appreciate help with this, thank you.

    this is the script for the rotation:
    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var speedForChange: int;
    4.  
    5. function Start () {
    6. }
    7. function Update () {
    8. var rotvar = speedForChange * Time.deltaTime;
    9.  
    10.         transform.Rotate(Vector3.up * rotvar, Space.World);
    11. }
     
    Last edited: Jul 24, 2014
  2. shahan

    shahan

    Joined:
    Jan 27, 2014
    Posts:
    25
    also how do i tweak the first person controller to be more ... spatially correct? the way the camera is now it's really hard to see when and where the collisions happen.
     
  3. shahan

    shahan

    Joined:
    Jan 27, 2014
    Posts:
    25
    please someone help! anything! point me to a tutorial for the kind of thing i'm doing.

    how do i get the petal bullets to 'shoot'. I've looked it up but can't find anything that applies closely enough for me to apply or for me to understand how it would apply because i'm new.
     
  4. shahan

    shahan

    Joined:
    Jan 27, 2014
    Posts:
    25
    What am I doing wrong? Is there a better place to voice these types of questions. I though WIPs would be right.

    Also can what I want to do here be done in C# with greater ease?