Re: Z - axis movement

MoveSetScript

    public BasicMoveInfo moveForward = new BasicMoveInfo();
    public BasicMoveInfo moveBack = new BasicMoveInfo();
    //my additions, these are the z-axis moves
    public BasicMoveInfo moveLeft = new BasicMoveInfo();
    public BasicMoveInfo moveRight = new BasicMoveInfo();     
    public BasicMoveInfo getHitSweep = new BasicMoveInfo();
    //and the reactions from being hit side-on
    public BasicMoveInfo getHitFromLeft = new BasicMoveInfo();
    public BasicMoveInfo getHitFromRight = new BasicMoveInfo();
   
    
         setBasicMoveAnimation(basicMoves.moveBack, "moveBack", WrapMode.Loop, BasicMoveReference.MoveBack);
        //my additions
        setBasicMoveAnimation(basicMoves.moveLeft, "moveLeft", WrapMode.Loop, BasicMoveReference.MoveLeft);
        setBasicMoveAnimation(basicMoves.moveRight, "moveRight", WrapMode.Loop, BasicMoveReference.MoveRight);
        setBasicMoveAnimation(basicMoves.getHitFromLeft, "getHitFromLeft", WrapMode.ClampForever, BasicMoveReference.getHitFromLeft);
        setBasicMoveAnimation(basicMoves.getHitFromRight, "getHitFromRight", WrapMode.ClampForever, BasicMoveReference.getHitFromRight);

Share

Thumbs up Thumbs down

Re: Z - axis movement

HitBoxes.cs

    Change all instances of Vector2 to Vector3
    //my addition vector2 - vector3
    public Vector3 offSet;

   void OnDrawGizmos() {
   //basically, update all your code with Vector3's where applicable, this DOES NOT include the new rectangle hit boxes, leave them alone.
       Vector3 hitBoxPosition = hitBox.position.position + new Vector3(hitBox.offSet.x, hitBox.offSet.y, hitBox.offSet.z);
   }
   
  

  

Share

Thumbs up Thumbs down

Re: Z - axis movement

CharacterEditorWindow.cs

    public void OnGUI(){
//without this, you wont be able to tweak the position of your hit volumes along all axes.
hitBoxesScript.hitBoxes[i].offSet = EditorGUILayout.Vector3Field("Off Set:", hitBoxesScript.hitBoxes[i].offSet);


//add this to enable side speed
 SubGroupTitle("Z-axis Movement");
                        characterInfo.physics.moveForwardSpeed = EditorGUILayout.FloatField("Move Side Speed:", characterInfo.physics.moveSideSpeed);                        
                        characterInfo.physics.highMovingFriction = EditorGUILayout.Toggle("High Moving Friction", characterInfo.physics.highMovingFriction);
                        characterInfo.physics.friction = EditorGUILayout.FloatField("Friction:", characterInfo.physics.friction);
                        EditorGUILayout.Space();


 characterInfo.physics.moveSideSpeed = EditorGUILayout.FloatField("Move Side Speed:", characterInfo.physics.moveSideSpeed);                        
}

For those changes, add them in near where the existing Horizontal movement code is. I have used one sidespeed variable for strafing, which is applied to both left and right movement. Walking forward and back have separate speeds.

That's all for tonight, but I will post more once I get my notes on the changes sorted. smile

Share

Thumbs up Thumbs down

Re: Z - axis movement

Thanks alot!

Share

Thumbs up Thumbs down

Re: Z - axis movement

ControlsScript.cs

 [HideInInspector]
    public int axis;
    //my addition for controlling speed of rot
    //my bools for testing character alignment
    public bool pFront, pRear, pLeft, pRight;
    //my bools for testing camera alignment
    public bool camFront, camRear, camLeft, camRight;

    //my additions
    Vector3 newMoveDirection;
    float h;
    float v;
    [HideInInspector]
    public int axis;
    private int moveDir;

    // for ring bounds
    Vector3 stageCentre = Vector3.zero;
    float radius = UFE.config.selectedStage.ringRadius;private float rotationSpeed;
    
    void Start()
    {
     if (gameObject.name == "Player1")
        {
            CamPointScript p1point = character.GetComponentInChildren<CamPointScript>();
            cameraScript.P1Trans = p1point.childEmpty;
        }
        if (gameObject.name == "Player2")
        {
            CamPointScript p2point = character.GetComponentInChildren<CamPointScript>();
            cameraScript.P2Trans = p2point.childEmpty;
        }
    }
    
     private void fixCharacterRotation()
    {
        if (currentState == PossibleStates.Down) return;      

        Transform _myTransform = character.transform;
        var playerLook = new Vector3(opponent.transform.position.x, character.transform.position.y, opponent.transform.position.z);
        character.transform.LookAt(playerLook);
    }
    
     private void validateRotation()
    {       
        //my addition
        if (myPhysicsScript.IsGrounded() || myPhysicsScript.freeze || currentMove != null) fixCharacterRotation();      
    }
    
     //turn to face opponent
    private void Rotating()
    {
        Transform _myTransform = character.transform;
        var playerLook = new Vector3(opponent.transform.position.x, character.transform.position.y, opponent.transform.position.z);
        character.transform.LookAt(playerLook);
      
    }
    
      private void translateInputs(AbstractInputController inputController)
    {
    if (inputRef.inputType == InputType.HorizontalAxis)
                {
     
                     //   inputRef.engineRelatedButton = mirror == 1 ? ButtonPress.Back : ButtonPress.Foward;
                     
                            if (camRight || camFront)
                            {
                                axis = -1;
                                myPhysicsScript.Move(1, inputController.GetAxisRaw(inputRef));
                                if (gameObject.name == "Player2")
                                {
                                    Debug.Log("camRight || camFront");
                                }
                            }
                            else if (camLeft || camRear)
                            {
                                axis = -1;
                                myPhysicsScript.Move(-1, -inputController.GetAxisRaw(inputRef));
                                if (gameObject.name == "Player2")
                                {
                                    Debug.Log("camLeft || camRear");
                                }
                            }
                   
                   
                            if (camRight || camFront)
                            {
                                axis = -1;
                                myPhysicsScript.Move(-1, inputController.GetAxisRaw(inputRef));
                                if (gameObject.name == "Player2")
                                {
                                    Debug.Log("camRight || camFront");
                                }
                            }
                            else if (camLeft || camRear)
                            {
                                axis = -1;
                                myPhysicsScript.Move(1, -inputController.GetAxisRaw(inputRef));
                                if (gameObject.name == "Player2")
                                {
                                    Debug.Log("camLeft || camRear");
                                }
                            }

                }
                if (inputRef.inputType == InputType.VerticalAxis)
                {
                   if (inputController.GetAxisRaw(inputRef) > 0)
                    {
                                if (!isBlocking)
                                {
                                    if (camRight || camFront)
                                    {
                                        axis = 2;
                                        myPhysicsScript.myMove(1, inputController.GetAxisRaw(inputRef));
                                    }
                                    else if (camLeft || camRear)
                                    {
                                        axis = -2;
                                        myPhysicsScript.myMove(-1, -inputController.GetAxisRaw(inputRef));
                                    }
                                }
                                else
                                {
                                    if (myInfo.physics.canJump)
                                    {
                                      etc...
                                        }
                                    }
                                }
                            }
                        }
                        
                    }
                    else if (inputController.GetAxisRaw(inputRef) < 0)
                    {
                       
                            if (!isBlocking)
                            {
                                if (camRight || camFront)
                                {
                                    axis = -2;
                                    myPhysicsScript.myMove(mirror, inputController.GetAxisRaw(inputRef));
                                }
                                else if (camLeft || camRear)
                                {
                                    axis = 2;
                                    myPhysicsScript.myMove(mirror, -inputController.GetAxisRaw(inputRef));
                                }
                            }
                            else
                            {
                                currentState = PossibleStates.Crouch;
                                if (!myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.crouching.name))
                                {
                                    if (!isBlocking && !myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.crouching.name))
                                        myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.crouching);

                                    if (isBlocking && !myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.blockingCrouchingPose.name))
                                        myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.blockingCrouchingPose);
                                }
                            }
                        }
                    }
                }


          
    }

Probably the single biggest one. smile Hopefully I didn't miss anything here, but if there are errors, let me know.

Share

Thumbs up Thumbs down

56 (edited by Steviebops 2014-12-22 11:45:07)

Re: Z - axis movement

According to my sourcetree, I think that's all the changes needed for v1.5. The older code I already posted makes up the rest of the functionality.
Again, any errors, post them here, and Ill try help out.

Share

Thumbs up +1 Thumbs down

Re: Z - axis movement

What's up Steviebops, first off thanks so much for the scripts! A question though, where do I place these scripts? I mean should I replace the original scripts with yours or add them somewhere in the default scripts? If I need to add them to the default scripts can you tell or recommend where to place them since I'm still new to programming and scripting. I don't won't to mess up any of the original scripts.

Share

Thumbs up Thumbs down

Re: Z - axis movement

Your best bet is to save a copy of all the original scripts. you might also look into a source control software, like sourcetree, so it's easier to manage changes.

In most cases you are adding to the existing scripts, Ive left the method names in so you know where they go.

As UFE is not open source, I can't post the full classes, so Ive tried to only post changes.

Share

Thumbs up Thumbs down

Re: Z - axis movement

I've encountered a small problem with my code. The hit boxes seem to be 'drifting' as I move. This only applies to boxes with an offset applied in the editor, for example, I add a collision sphere to my sword, then offset it so it's at the centre of the blade.

When my characters strafe around each other, the sphere moves off centre. I think it might have something to do with Global vs. local co-ordinates, but I don't have a fix yet.

I will ask on the main forum for help.

Share

Thumbs up Thumbs down

Re: Z - axis movement

OK, I think I might have this sorted.
In the HitBoxesScript.cs

Change the line

  Vector3 hitBoxPosition = hitBox.position.position + new Vector3(hitBox.offSet.x, hitBox.offSet.y, hitBox.offSet.z);

To

Vector3 hitBoxPosition = hitBox.position.position + transform.TransformDirection( new Vector3(hitBox.offSet.x, hitBox.offSet.y, hitBox.offSet.z));

And for the Hurtbox, change

hurtBoxPosition += new Vector3(hurtBox.offSet.x * -mirrorAdjust, hurtBox.offSet.y, hurtBox.offSet.z);

To

hurtBoxPosition += transform.TransformDirection(new Vector3(hurtBox.offSet.x * -mirrorAdjust, hurtBox.offSet.y, hurtBox.offSet.z));

That seems to change the offset to local space,instead of World.

Share

Thumbs up +1 Thumbs down

61 (edited by roswell108 2015-03-26 21:00:53)

Re: Z - axis movement

Steviebops wrote:

ControlsScript.cs

 [HideInInspector]
    public int axis;
    //my addition for controlling speed of rot
    //my bools for testing character alignment
    public bool pFront, pRear, pLeft, pRight;
    //my bools for testing camera alignment
    public bool camFront, camRear, camLeft, camRight;

    //my additions
    Vector3 newMoveDirection;
    float h;
    float v;
    [HideInInspector]
    public int axis;
    private int moveDir;

    // for ring bounds
    Vector3 stageCentre = Vector3.zero;
    float radius = UFE.config.selectedStage.ringRadius;private float rotationSpeed;
    
    void Start()
    {
     if (gameObject.name == "Player1")
        {
            CamPointScript p1point = character.GetComponentInChildren<CamPointScript>();
            cameraScript.P1Trans = p1point.childEmpty;
        }
        if (gameObject.name == "Player2")
        {
            CamPointScript p2point = character.GetComponentInChildren<CamPointScript>();
            cameraScript.P2Trans = p2point.childEmpty;
        }
    }
    
     private void fixCharacterRotation()
    {
        if (currentState == PossibleStates.Down) return;      

        Transform _myTransform = character.transform;
        var playerLook = new Vector3(opponent.transform.position.x, character.transform.position.y, opponent.transform.position.z);
        character.transform.LookAt(playerLook);
    }
    
     private void validateRotation()
    {       
        //my addition
        if (myPhysicsScript.IsGrounded() || myPhysicsScript.freeze || currentMove != null) fixCharacterRotation();      
    }
    
     //turn to face opponent
    private void Rotating()
    {
        Transform _myTransform = character.transform;
        var playerLook = new Vector3(opponent.transform.position.x, character.transform.position.y, opponent.transform.position.z);
        character.transform.LookAt(playerLook);
      
    }
    
      private void translateInputs(AbstractInputController inputController)
    {
    if (inputRef.inputType == InputType.HorizontalAxis)
                {
     
                     //   inputRef.engineRelatedButton = mirror == 1 ? ButtonPress.Back : ButtonPress.Foward;
                     
                            if (camRight || camFront)
                            {
                                axis = -1;
                                myPhysicsScript.Move(1, inputController.GetAxisRaw(inputRef));
                                if (gameObject.name == "Player2")
                                {
                                    Debug.Log("camRight || camFront");
                                }
                            }
                            else if (camLeft || camRear)
                            {
                                axis = -1;
                                myPhysicsScript.Move(-1, -inputController.GetAxisRaw(inputRef));
                                if (gameObject.name == "Player2")
                                {
                                    Debug.Log("camLeft || camRear");
                                }
                            }
                   
                   
                            if (camRight || camFront)
                            {
                                axis = -1;
                                myPhysicsScript.Move(-1, inputController.GetAxisRaw(inputRef));
                                if (gameObject.name == "Player2")
                                {
                                    Debug.Log("camRight || camFront");
                                }
                            }
                            else if (camLeft || camRear)
                            {
                                axis = -1;
                                myPhysicsScript.Move(1, -inputController.GetAxisRaw(inputRef));
                                if (gameObject.name == "Player2")
                                {
                                    Debug.Log("camLeft || camRear");
                                }
                            }

                }
                if (inputRef.inputType == InputType.VerticalAxis)
                {
                   if (inputController.GetAxisRaw(inputRef) > 0)
                    {
                                if (!isBlocking)
                                {
                                    if (camRight || camFront)
                                    {
                                        axis = 2;
                                        myPhysicsScript.myMove(1, inputController.GetAxisRaw(inputRef));
                                    }
                                    else if (camLeft || camRear)
                                    {
                                        axis = -2;
                                        myPhysicsScript.myMove(-1, -inputController.GetAxisRaw(inputRef));
                                    }
                                }
                                else
                                {
                                    if (myInfo.physics.canJump)
                                    {
                                      etc...
                                        }
                                    }
                                }
                            }
                        }
                        
                    }
                    else if (inputController.GetAxisRaw(inputRef) < 0)
                    {
                       
                            if (!isBlocking)
                            {
                                if (camRight || camFront)
                                {
                                    axis = -2;
                                    myPhysicsScript.myMove(mirror, inputController.GetAxisRaw(inputRef));
                                }
                                else if (camLeft || camRear)
                                {
                                    axis = 2;
                                    myPhysicsScript.myMove(mirror, -inputController.GetAxisRaw(inputRef));
                                }
                            }
                            else
                            {
                                currentState = PossibleStates.Crouch;
                                if (!myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.crouching.name))
                                {
                                    if (!isBlocking && !myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.crouching.name))
                                        myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.crouching);

                                    if (isBlocking && !myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.blockingCrouchingPose.name))
                                        myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.blockingCrouchingPose);
                                }
                            }
                        }
                    }
                }


          
    }

Probably the single biggest one. smile Hopefully I didn't miss anything here, but if there are errors, let me know.

if (myInfo.physics.canJump)
{
         etc...
}

? I get a lot of errors even without attempting to fill that in.

There is a NullReference on Vector3 desiredPos = midPoint + Perpendicular.normalized * dist - _rigidbody.position; from CameraScript.cs

Share

Thumbs up Thumbs down

Re: Z - axis movement

Do you have a rigidbody on your camera?
Im sorry if I neglected to mention that was necessary, I was so focused on code, I forgot the Editor setup hmm

If you don't already have one, here's the settings I have on mine.
Mass:1
Drag:0
Angular Drag 0.05
Uncheck Use Gravity
Uncheck IsKinematic
Interpolate: None
Collision Detection: Discrete

Uncheck ALL constraints.


Also, add a Sphere collider so it can collide properly with any walls around your stage. 
Material: Frictionless

Share

Thumbs up Thumbs down

Re: Z - axis movement

Why are you using a rigidbody on the camera?  That's not normally what you'd attach a rigidbody component to...

Share

Thumbs up Thumbs down

64 (edited by roswell108 2015-03-27 07:38:05)

Re: Z - axis movement

YumChaGames wrote:

Why are you using a rigidbody on the camera?  That's not normally what you'd attach a rigidbody component to...

^ This. I saw the rigidbody note in the code, but that seemed... odd...

Steviebops wrote:

Do you have a rigidbody on your camera?
Im sorry if I neglected to mention that was necessary, I was so focused on code, I forgot the Editor setup hmm

If you don't already have one, here's the settings I have on mine.
Mass:1
Drag:0
Angular Drag 0.05
Uncheck Use Gravity
Uncheck IsKinematic
Interpolate: None
Collision Detection: Discrete

Uncheck ALL constraints.


Also, add a Sphere collider so it can collide properly with any walls around your stage. 
Material: Frictionless

Even with it, I still get the same error.

I just realized I never went back and corrected the awake() I copied from your changes to be Awake(). Unity is case sensitive on the overrides. OnGUI, Update, Start, etc.

Now the camera is somewhat working, but I still don't have z-axis movement. I think it has something to do with not having that whole section I was quoting because it didn't seem to match up to the code I had from 1.5

Share

Thumbs up Thumbs down

65 (edited by Steviebops 2015-03-27 10:11:54)

Re: Z - axis movement

The camera needs to collide with the outer walls of any stage, hence the collider. The Rigidbody is to add velocity without breaking the physics.

As for the

if (myInfo.physics.canJump)
{
         etc...
}

That code remains unchanged from the original UFE scripts, so you're not actually changing it, I just didn't post the full code there as it's not allowed.

Share

Thumbs up Thumbs down

Re: Z - axis movement

@Roswell, Ive sent you a PM with that code snippet.

Share

Thumbs up Thumbs down

67 (edited by Steviebops 2015-03-27 11:57:07)

Re: Z - axis movement

This video shows the basics of what z-axis actually is, not all the features such as direction-specific attacks are shown, just the movement and dodging.

[media]http://youtu.be/rITScc3UVKg[/media]

The quality is a bit potato, but it shows what the basics actually are, as some people asked me what I meant by z-axis.

Share

Thumbs up +2 Thumbs down

Re: Z - axis movement

I gave up lol

It was too hard to take two whole sets of source and try to figure out what changed from the download, then what changed from the first mod. I think you mentioned adding the function names to find where things went, but it didn't really say if we leave the stuff that is already there or replace it.

I imagine it would be much easier if you are using git or something to make one big diff of the changes. That wouldn't expose the original source but it would do the + / - thing to make it easier to find.

Share

Thumbs up Thumbs down

Re: Z - axis movement

I use Sourcetree/Bitbucket, and I will look into how to do that, do you know if there's a tutorial on posting only the differences so I can get a headstart?

That would save everyone some hassle smile

Share

Thumbs up Thumbs down

Re: Z - axis movement

Steviebops wrote:

I use Sourcetree/Bitbucket, and I will look into how to do that, do you know if there's a tutorial on posting only the differences so I can get a headstart?

That would save everyone some hassle smile

http://stackoverflow.com/questions/2143 … -bitbucket

Share

Thumbs up Thumbs down

Re: Z - axis movement

You can still get the UFE code from that, and that's the problem, it can't be posted publicly. The diffs are listed alongside the source code.

Share

Thumbs up Thumbs down

Re: Z - axis movement

Steviebops wrote:

You can still get the UFE code from that, and that's the problem, it can't be posted publicly. The diffs are listed alongside the source code.

I'm not familiar with bitbucket, but git has a commandline option for making patches that gives you just the changes. I'll have to look if there is anything similar. All I found before was web stuff.

Share

Thumbs up Thumbs down

Re: Z - axis movement

I saw the same when I looked at Bitbucket topics Tomorrow Ill look into patches in more detail, if Bitbucket is no good, then I'll set up a git version, either way, if it's possible to post the changes in patch form, Ill get it done.

Share

Thumbs up Thumbs down

Re: Z - axis movement

Steviebops wrote:

I saw the same when I looked at Bitbucket topics Tomorrow Ill look into patches in more detail, if Bitbucket is no good, then I'll set up a git version, either way, if it's possible to post the changes in patch form, Ill get it done.

Thanks. I have been using github for mine, but Bitbucket gives you a lot of the same stuff github makes you pay for. It would be a different story if I didn't have a discount on private repos.

Share

Thumbs up Thumbs down

75 (edited by Steviebops 2015-03-30 14:23:55)

Re: Z - axis movement

I found a way to create a patch in Sourcetree, as it seems Github doesn't allow private repos on the free account.

If anyone would like to test it, I can send it on.

Share

Thumbs up Thumbs down