Thursday, 11 August 2011

Prototype viewing 1

Ive done the move script for the player. for it to be able to jump and hit the stars

This is the move script

i made it move by putting on a script which is;

    void Update ()
   
    {
        float x = Input.GetAxis("Mouse X") ;

        this.transform.position = new Vector3( Mathf.Clamp(x + this.transform.position.x, edge, -edge),
                                                this.transform.position.y,
                                                0);
basically the character will be controled by the mouse.

i added a plane made prevented double jumping with;

void OnTriggerStay(Collider other)
   {
       if (Input.GetButtonDown("Jump"))
       {
           this.rigidbody.AddForce(transform.up *jumpForce);
       }

this is the On trigger stay function which prevents double jumping.

This is the function that make the player boost up when colliding the star;

   void OnTriggerEnter(Collider other)
    {

        if (other.tag == "star")
        {

            this.rigidbody.velocity = new Vector3(0, starForce, 0);

Then the Spawning of the star;
  #region Start
    // Use this for initialization
    void Start()
    {

        for (int i = 1; i <= 50; i++)
        {
            Instantiate(star, transform.position, transform.rotation);
        }
    }


For now this works.
But when we combine the move script together with my group mades other script, it goes hay wire so For now this will do.

What i did to for testing;

No comments:

Post a Comment