Jump to content

  • Log In with Google      Sign In   
  • Create Account


Sugavanas

Member Since 24 Oct 2012
Offline Last Active Nov 26 2013 11:15 AM
*----

Topics I've Started

Group Discussion Site

15 September 2013 - 01:39 AM

First of all, i had absolutely no idea where to post this topic.So, please don't vote negative. I have a group and currently we want to start developing a game. It would be easy if there is any private site for this type of discussion. I also prefer having a source code somehting similar to like that so i can upload it to my server and start it with my friends. Is there any source code available. I don't mind paying for the source codes :)


All Game Developers are Invited

14 June 2013 - 01:21 PM

Guys, if you are a game developer or want to be one and learning, and you want a team, you can join here  <snip> .
We are thinking of starting a mmo rpg projec and everyone is invited. You will be chosen according to the work you sumbit...(you will be added to the group immediately but you will only be chosen for projects accrding to your work). 


Sharing gameobjects, variables, strings between scripts

04 May 2013 - 02:28 PM

Hello guys, i am trying to share things between scripts. The first thing i would like to share is a type of level:

I have two levels, main menu and one game level. So the thing is the player selects a type of level in the main menu (like what type of models to use). There are total two type of different models. So now when the player clicks play after selecting the model, i want the script in the game level to receive the type of model information.

in this case, lets take it theme1 and theme2.

So if the player checks theme1, i want the script in this level to make a variable called result and point it to a script called TypeTheme1.
now, in the script whenever i point result i will get the things from TypeTheme1 scripts.

Now i can do with changing the models.



Second is how do i share gameobjects models which are public

so i have a script,

 

public GameObject m_Straight_S_Tile;

public GameObject m_Left_S_Tilee;
 
public GameObject m_Right_S_Tile;
 
public GameObject m_T_S_Tile;
 
public GameObject m_Jump_S_Tile;

public GameObject m_Obstacle_S_Tile;

 

now in the inspector i have choosed the models for the script directly into the script import setting. 

So, now in the other script if I add the scripts name can i access the gameobjects which are public and in some cases also public floats, vaiables and function.





i don't need the gameobject.find("")getcomponent<>;
it's because this things are in different levels.

I am actually connecting between scripts but can't s but get this done, i think i won't use that scripts in any object and use one main script to get the public functions from the script.

It's important as i need to share between highscore, store items and many.

Need it in C#
and if you know it in .js, add it too, i can translate a little

 

 


Writing Windows 8 games

27 April 2013 - 10:56 AM

Actually, how do i write a 3d windows 8 game ?????? and also is there any way to do it in Unity....I know the way of writing it with JS or C# or C++ but still any engine out there


Jumping problem in Animator controller in unity3d

25 March 2013 - 10:13 PM

confused.png Hello i saw the mecanim animation tutorial by unity and get to know abt it. So i made my own scene and made a controller with a new player using the same script from unity. I used new animation files from the 150 animation which unity gave for free.

Here is the script

 

 

c#

using UnityEngine;

using System.Collections;

 

// Require these components when using this script

[RequireComponent(typeof (Animator))]

[RequireComponent(typeof (CapsuleCollider))]

[RequireComponent(typeof (Rigidbody))]

public class BotControlScript : MonoBehaviour

{

    [System.NonSerialized]                  

    public float lookWeight;                    // the amount to transition when using head look

    

    [System.NonSerialized]

    public Transform enemy;                     // a transform to Lerp the camera to during head look

    

    public float animSpeed = 1.5f;              // a public setting for overall animator animation speed

    public float lookSmoother = 3f;             // a smoothing setting for camera motion

    public bool useCurves;                      // a setting for teaching purposes to show use of curves

 

    

    private Animator anim;                          // a reference to the animator on the character

    private AnimatorStateInfo currentBaseState;         // a reference to the current state of the animator, used for base layer

    private AnimatorStateInfo layer2CurrentState;   // a reference to the current state of the animator, used for layer 2

    private CapsuleCollider col;                    // a reference to the capsule collider of the character

    

 

    static int idleState = Animator.StringToHash("Base Layer.Idle");    

    static int locoState = Animator.StringToHash("Base Layer.Locomotion");          // these integers are references to our animator's states

    static int jumpState = Animator.StringToHash("Base Layer.Jump");                // and are used to check state for various actions to occur

    static int jumpDownState = Animator.StringToHash("Base Layer.JumpDown");        // within our FixedUpdate() function below

    static int fallState = Animator.StringToHash("Base Layer.Fall");

    static int rollState = Animator.StringToHash("Base Layer.Roll");

    static int waveState = Animator.StringToHash("Layer2.Wave");

    

 

    void Start ()

    {

        // initialising reference variables

        anim = GetComponent<Animator>();                      

        col = GetComponent<CapsuleCollider>();              

        enemy = GameObject.Find("Enemy").transform; 

        if(anim.layerCount ==2)

            anim.SetLayerWeight(1, 1);

    }

    

    

    void FixedUpdate ()

    {

        float h = Input.GetAxis("Horizontal");              // setup h variable as our horizontal input axis

        float v = Input.GetAxis("Vertical");                // setup v variables as our vertical input axis

        anim.SetFloat("Speed", v);                          // set our animator's float parameter 'Speed' equal to the vertical input axis              

        anim.SetFloat("Direction", h);                      // set our animator's float parameter 'Direction' equal to the horizontal input axis        

        anim.speed = animSpeed;                             // set the speed of our animator to the public variable 'animSpeed'

        anim.SetLookAtWeight(lookWeight);                   // set the Look At Weight - amount to use look at IK vs using the head's animation

        currentBaseState = anim.GetCurrentAnimatorStateInfo(0); // set our currentState variable to the current state of the Base Layer (0) of animation

        

        if(anim.layerCount ==2)     

            layer2CurrentState = anim.GetCurrentAnimatorStateInfo(1);   // set our layer2CurrentState variable to the current state of the second Layer (1) of animation

        

        

        // LOOK AT ENEMY

        

        // if we hold Alt..

        if(Input.GetButton("Fire2"))

        {

            // ...set a position to look at with the head, and use Lerp to smooth the look weight from animation to IK (see line 54)

            anim.SetLookAtPosition(enemy.position);

            lookWeight = Mathf.Lerp(lookWeight,1f,Time.deltaTime*lookSmoother);

        }

        // else, return to using animation for the head by lerping back to 0 for look at weight

        else

        {

            lookWeight = Mathf.Lerp(lookWeight,0f,Time.deltaTime*lookSmoother);

        }

        

        // STANDARD JUMPING

        

        // if we are currently in a state called Locomotion (see line 25), then allow Jump input (Space) to set the Jump bool parameter in the Animator to true

        if (currentBaseState.nameHash == locoState)

        {

            if(Input.GetButtonDown("Jump"))

            {

                anim.SetBool("Jump", true);

            }

        }

        

        // if we are in the jumping state... 

        else if(currentBaseState.nameHash == jumpState)

        {

            //  ..and not still in transition..

            if(!anim.IsInTransition(0))

            {

                if(useCurves)

                    // ..set the collider height to a float curve in the clip called ColliderHeight

                    col.height = anim.GetFloat("ColliderHeight");

                

                // reset the Jump bool so we can jump again, and so that the state does not loop 

                anim.SetBool("Jump", false);

            }

            

            // Raycast down from the center of the character.. 

            Ray ray = new Ray(transform.position + Vector3.up, -Vector3.up);

            RaycastHit hitInfo = new RaycastHit();

            

            if (Physics.Raycast(ray, out hitInfo))

            {

                // ..if distance to the ground is more than 1.75, use Match Target

                if (hitInfo.distance > 1.75f)

                {

                    

                    // MatchTarget allows us to take over animation and smoothly transition our character towards a location - the hit point from the ray.

                    // Here we're telling the Root of the character to only be influenced on the Y axis (MatchTargetWeightMask) and only occur between 0.35 and 0.5

                    // of the timeline of our animation clip

                    anim.MatchTarget(hitInfo.point, Quaternion.identity, AvatarTarget.Root, new MatchTargetWeightMask(new Vector3(0, 1, 0), 0), 0.35f, 0.5f);

                }

            }

        }

        

        

        // JUMP DOWN AND ROLL 

        

        // if we are jumping down, set our Collider's Y position to the float curve from the animation clip - 

        // this is a slight lowering so that the collider hits the floor as the character extends his legs

        else if (currentBaseState.nameHash == jumpDownState)

        {

            col.center = new Vector3(0, anim.GetFloat("ColliderY"), 0);

        }

        

        // if we are falling, set our Grounded boolean to true when our character's root 

        // position is less that 0.6, this allows us to transition from fall into roll and run

        // we then set the Collider's Height equal to the float curve from the animation clip

        else if (currentBaseState.nameHash == fallState)

        {

            col.height = anim.GetFloat("ColliderHeight");

        }

        

        // if we are in the roll state and not in transition, set Collider Height to the float curve from the animation clip 

        // this ensures we are in a short spherical capsule height during the roll, so we can smash through the lower

        // boxes, and then extends the collider as we come out of the roll

        // we also moderate the Y position of the collider using another of these curves on line 128

        else if (currentBaseState.nameHash == rollState)

        {

            if(!anim.IsInTransition(0))

            {

                if(useCurves)

                    col.height = anim.GetFloat("ColliderHeight");

                

                col.center = new Vector3(0, anim.GetFloat("ColliderY"), 0);

                

            }

        }

        // IDLE

        

        // check if we are at idle, if so, let us Wave!

        else if (currentBaseState.nameHash == idleState)

        {

            if(Input.GetButtonUp("Jump"))

            {

                anim.SetBool("Wave", true);

            }

        }

        // if we enter the waving state, reset the bool to let us wave again in future

        if(layer2CurrentState.nameHash == waveState)

        {

            anim.SetBool("Wave", false);

        }

    }

}

 

And all of them worked correctly with moving forward back. I arranged them made it settings and everything. But when i do for jump, it jumps correctly and continue to jump when i press up button. But when i replace it with my old jump file using the sme pace and position it jumps correctly. I know that i missed one setting between that two files. Below in the attachment i have added those two fbx files, please anyone see it and say what I did wrong, if you want more files including the controllers


PARTNERS