Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - gary-unikronsoftware

Pages: 1 2 [3] 4
31
Support / Re: Saving problems
« on: August 23, 2013, 09:18:16 am »
This is a known issue with version 2.1 of the toolkit camera, and is fixed in version 2.2.  Unity will say that the scene isn't saved, but actually it has been.

32
Support / Re: 2D Toolkit Mole Tutorial Error
« on: August 23, 2013, 09:12:24 am »
Did you put this line (or a one similar to it)...

Code: [Select]
ScoreScript.Score += mole.Whacked ? 0 : 10;
in the ScoreScript?  If so, that's why it's not working, it needs to go in the MainGameScript at the point where you detect a successful mole hit.

33
If I understand this correctly, your tk2dCamera sprites are being drawn but they are being drawn behind your GUI sprites?  This is what you would expect, so I'm not sure where the problem is?

34
I am also using Unity 4.2

35
I have tried to recreate the problem using a NGUI camera and a tk2d camera in my environment using the same settings as you have, but both the GUI element and the sprite were drawn as expected.

Can you export a simple copy of your project which shows the problem happening, and send to our support email support@unikronsoftware.com so we can investigate further.

Thanks.

36
If you disable your NGUI camera can you see the sprites from the tk2d camera?  Can you also post screenshots of how both your cameras are set up?

thanks.

37
Hi,

On the settings for your NGUI camera, try changing the Clear Flags value to 'depth only' to see if that fixes the problem.

Thanks.

38
Support / Re: How to move a tk2dcamera with C# script
« on: August 13, 2013, 10:01:13 am »
Oh, one other thing - do you have debug logs turned off so any errors aren't being shown?  (The buttons on the top-right of the console window toggles errors and warning messages).

39
Support / Re: How to move a tk2dcamera with C# script
« on: August 13, 2013, 09:50:14 am »
Hi,

I have just tried a variation of your script and it works fine...

Code: [Select]
using UnityEngine;
using System.Collections;

public class GameScript : MonoBehaviour
{
public tk2dCamera Cam;
public float moveX;

void Start ()
{
Debug.Log("HERET");
moveX = 0;
}

void Update ()
{
if(Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
{
Debug.Log("HERE");
moveX += 20;

Vector3 pos = Cam.transform.position;

pos.x += moveX;

Cam.transform.position = pos;
}
}
}

Can I suggest a few things to check...

- Have you also added an Awake() function to the script and does this get called and execute correctly?  If this function breaks it would stop the Start and Update functions getting called.
-  Do you get any errors when the code compiles or runs?
-  Did you remember to drag the tk2dCamera object from Hierarchy into the script's Cam slot?

If all of that is okay, I'm at a loss at what more to suggest.

40
Support / Re: Flipping sprite animation for moving other direction.
« on: August 12, 2013, 04:56:01 pm »
Hi,

You were nearly right with your first attempt - the line

Code: [Select]
anim.Sprite.scale = new Vector3(-1, 1, 1);
before the play line should reverse the sprite.  Alternatively

Code: [Select]
anim.Sprite.FlipX = true;
should also work - note that FlipX is a property, not a function.

Hope this helps.

41
Support / Re: Right size for images
« on: August 12, 2013, 09:55:30 am »
Hi,

Is your preview (Game) window in 'Free Aspect'?  If so, use the drop-down box to change the resolution of the window and the camera should pick it up.

42
Support / Re: how to setup colliders programatically
« on: August 07, 2013, 09:04:19 pm »
Hi,

Is there any reason why you are using a mesh collider?  It's just that these are for more complex objects and the bounds are calculated based on the mesh of the object.  What you're trying to do is fairly straight forward using a simple box collider, something like:

Code: [Select]
BoxCollider collider;
if(_sprite.GetComponent<BoxCollider>() == null)
{
collider = _sprite.gameObject.AddComponent<BoxCollider>();
}
else
{
collider = _sprite.gameObject.GetComponent<BoxCollider>();
}

collider.center = new Vector3 (0, 0, 0);
collider.size = new Vector3(10,10,1);

Does this help?

43
Support / Re: Rotate object on Z-axis to face current mouse position
« on: August 06, 2013, 10:45:04 am »
Hi Guidez,

I'm not sure exactly what you're trying to do, as I created a scene and used your code on some objects and the behaviour appeared to be what you wanted.  Bear in mind that the if you are holding down the mouse and moving it (i.e. so the rotation will be constantly updated on the objects), objects further away from the mouse will have less distance to rotate to face the mouse and therefore appear to rotate 'slower'.

I played around with the code and came up with a seemingly simpler version that appears to work with the limited testing I did, that doesn't use distances and adding force, but you get the same effect...

 void FixedUpdate()
   {
        if (Input.GetButton("Fire2"))
      {
            //Grab the current mouse position on the screen
            mousePosition = camera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x,Input.mousePosition.y, Input.mousePosition.z));

   Vector3 relativePosition = mousePosition - gameObject.transform.position;;

            //Rotates toward the mouse
            rigidbody.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(relativePosition.y, relativePosition.x) * Mathf.Rad2Deg - 90);

       }//End Move Towards If Case

    }//End Fire3 If case


Maybe try and start with that and build up from there to get the results you want?

44
Hi Freeze,

It is most likely due to you looking at the Scene view in Perspective.  Turn the perspective off and set the view to 'Back', and the Scene view should now show you the game objects correctly sorted and how you will see them in the game.

Let me know if that fixes it for you.

Thanks.

45
Support / Re: UI events not responding correctly
« on: July 29, 2013, 11:28:39 am »
Hi,

Yes, the code is working as expected, in that once you click down with the mouse button you are no longer 'hovering'.  Also the OnRelease will return the item you originally clicked down on. 

If you are trying to create a drag-and-drop effect, would it be possible to add something to your script like this (in the Update function): 

      if(Input.GetMouseButton (0))
      {
         Ray ray = gameCam.ScreenPointToRay(Input.mousePosition);
   
         RaycastHit[] hits = Physics.RaycastAll(ray, Mathf.Infinity);
         
         Debug.Log(hits.Length);
         foreach (RaycastHit hit in hits)
         {
            // Do something
         }
      }

So basically this will return all colliders the ray hits whilst the mouse button is held down (although the colliders aren't guaranteed to be in any particular order).

Pages: 1 2 [3] 4