Friday, March 25, 2011

Week 11

   For this week, I made a sphere of randomly spawned asteriods using a Random.insideUnitSpere * radius, which will randomly spawn asteriods assuming the transform[] is set within whatever I make the raduis, say for example I set radius equals 5, the 3 axis will equal 5 for the maximum size of the sphere and asteriods will be randomly placed inside. Several issues with the code Instantiate (asteriod[asteriodToSpawn], Random.insideUnitSphere * 150, Quaternion.LookRotation(center)); is that the insideUnitSphere * radius takes up the spot for any transform.position/rotate slot so I had to make a separate code for the actual movement of the asteriods. Which for the most part works, except I had to us addForce and using Random.value -0.5 for the xyz and put transform.Rotate(x,y,z) into the update function, putting it into fixed update causes it to go faster then what I would want it to, and using addTorque on the rotational axis even with the random variables in update, it builds up from slow then goes fast.

    I was trying to get a randomrotate setup within the Start function but there is something missing, not sure what yet. But with what I have, when played the asteriods will go forward or backup based on the way it was facing and will also randomly rotate along an axis and each of the speeds for these is random, so some go faster then others or rotate faster.

    A minor issue that came up is an asteriod will go in a circle, not all of them will but some do. A major issue is the asteriods go thru each other, though I wasn`t concerned with asteriods spawning on top of each other yet. I put a oncollisionenter funtion with a print and nothing prints, and I did put a cube inside the sphere with a rigidbody and when I move it around, it will bounce of the asteriods but the asteriods dont do much else. Overall, took longer this done then what I had to do last week. Around 4 hours.

No comments:

Post a Comment