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.


Topics - JerryCic

Pages: [1]
1
Support / How do i build a box collider at runtime.
« on: February 14, 2012, 02:33:41 am »
Hi

I have a sprite in the hierarchy, it has a box collider placed there using the toolkits' edit.
At runtime, i add several other sprites of various sizes to the right of the initial sprite as children.

I can use the bounds extents of all the sprites to create a vector3 that is the extent of the box collider that i want to build.

I can also determine where the center of that collider should be.

I have tried to modify the existing collider, by setting its bounds.extents vector. this did not work.

basically I want a collider that covers the entire set of sprites.

How can i modify the collider or simply create a new collider that essentially will cover the entire set of sprites?

I have a script attached to the parent sprite. the problem is that the script doesnt execute for the children. The script allows the entire group to move its position via mouse or touch drag and drop with glide and boundaries.

If I create a box collider for each sprite, then i would have to place the script in each sprite. That would mess up some of my persistant variables in that live from update to update within each script intance.

I have tried having an empty game object act as the container, as well as trying the polygon convex mesh. I have tried the build() function. I am plugging away but have come up against the wall.

Thanks
Jerry C

2
Support / Still can't place a sprite in the right place.
« on: February 12, 2012, 05:57:37 am »
Hi

Sorry to be so confused at such a simple task.

I have a 800x480 sprite placed at 0,0,10
I have a 120x400 sprite i want to place so that the lower left corner matches the lower left corner of the larger sprite.
my camera is ortho size=1
my target height is 480

I have tried to use the ScreenToWorld and visa versa but cannot get it to line up.
Everything has pixel perfect set up.

I have tried this:
           
            // find the center of the screen and large (background) sprite
            Vector3 v = myCamera.WorldToScreenPoint(new Vector3(0,0,0));
            // move 340 pixels to the left of center
            // move 40 pixels down from center
            Vector3 s = new Vector3(v.x - 340, v.y - 40, v.z);
            GameObject.Find("Staff").transform.position = s;

but it places it too far to the left like about 40 pixels too far.
The y coordinate looks ok.
What am i doing wrong?

Thanks
Jerry           

3
Support / how to determine the exact position when instantiating a prefab.
« on: February 12, 2012, 01:19:49 am »
Hi
 
I have a gameobject called "Staff".
It is the parent of one prefab called "spGClef".
When i click on a button, i want to make the staff into one that has 6 children. 1 "spGClef", 4 "spMeasure", and 1 "spEnd".
I can do all that quite well.
What i cannot seem to do is get the positions as perfect end to end arrangement.
My sprite collections have "Target Height"=480.
My camera scale is 1,1,1 ortho size=1.
From Trial and error i have discovered that one pixel=.004166666 in the scale of x or y
Since the width of my "spGclef" is known to be 120, then my first measure must be placed 120 pixels to the right of the "spGClef" object. That is (.004166666 * 120)=0.5.

1) how can i determine the exact width of my sprite relative to the screen.width in pixels?
2) how can i determine mathematically the magic number (.00416666 in my case) so that i can get exact end to end placement of sprites dynamically at runtime?

EDIT: I also need to add a box colider to the resulting collective object so i need to know the final size for the collider.

Thank you up front.
Jerry C

4
Support / Versions and How to upgrade.
« on: February 11, 2012, 05:57:36 pm »
Please pardon my lack of knowledge.

I have Unity 5.4.1
I have 2dToolkit 1.51a

I have downloaded the 1.56 Final

Before i do anything, Do i have to upgrade my current version of Unity? (to 5.4.2)?

If so, thats ok, Its just that i tend to not upgrade unless i have to.
This odd behavior comes from Microsoft upgrades that break things.

The other question is where do i place my ".unitypackage"?
I dont even know where my 1.51a is.
I found a folder "C:\Program Files\Unity\Editor\Standard Packages" but my 2dtoolkit package is not there.
But everything is working fine.

I want to upgrade to 2dTK 1.56 because i need diceing.

Thank You
Jerry C

Pages: [1]