This question already has answers here:
Scale gameobject on just one side
(2 answers)
Closed 4 years ago.
I want to scale the 3d ibject from one side this problem I am going to elaborate by taking slider example.
As per the image when I am scaling it is scaled through center. I want to fix the left side as static and scale the slider to only right side.
Set this objects pivot point to the left side.
I'm asuming you are talking about the Image component. It uses a RectTransform where you can set the pivot points like this:
or simply open that menu, hold Shift + Alt and click there:
Or alternative make this object a child of another empty GameObject.
Set this objects position so that the left point matches the parent's pivot point. Than scale the new parent object instead.
Related
This question already has answers here:
Wrapping lines/polygons across the antimeridian in Leaflet.js
(3 answers)
Closed 1 year ago.
I am developing an application which needs to show a polyline which occassionally crosses the dateline. Problem is longitude bounds are -180 and +180. I have fenagled things to determine the index of the dateline in the array of coordinates. After crossing the index I just add +360 or -360 to continue the line as-is. This works and it shows the polyline. There is one catch. The user has to move the map left or right over the dateline. When that happens the polyline appears. This is obviously not a good solution.
Has anybody figured out how to display a polyline over dateline properly in leaflet from the get-go? Meaning without the need to move the map left or right to cross the dateline to make the polyline appear.
move the map left or right to cross the dateline to make the polyline appear
From the behaviour you describe, you probably have the map worldCopyJump option enabled.
With this option enabled, the map tracks when you pan to another "copy" of the world and seamlessly jumps to the original one so that all overlays like markers and vector layers are still visible.
But in your very case, your feature exists only on one "edge" of the world, so when the map jumps to the other edge, it looks like your feature disappeared.
In that case, simply remove that option from your map.
This question already has answers here:
Divide a number by a Vector3
(3 answers)
Closed 1 year ago.
In Unity I am trying to make the character crouch by scaling it's localScale.y and CapsuleCollider.height variables. But, if I change the localScale on the y axis of the parent GameObject which is the player, it's gun also gets scaled and it looks like it has been squished.
How will I change the localScale.y variable of the parent GameObject without affecting it's Cild GameObject?
You have 3 options here, first you can separate the hierarchy as mentioned by 3Dave to immediately resolve this.
Second you can use the Unity animator to create an animation that scales the object and adjust the scale of the child to counteract the parent scale.
Third (really not recommended) to create a complicated calculation to sort of inverse the scale of the parent i.e. if parent scale is 0.9, 0.9, 0.9 set the child to 1.1, 1.1, 1.1 and etc ( Not even sure this would work ).
There might be something else you can do, but these are the 3 solutions that immediately pop up in my head.
I want to create 2d game. The game is similar to the Scale Puzzle. I've already created nearly all the functionality. Only the last remains.
.
This is example.
And that's how I draw shapes.
.
I click inside a white square, and after 1 seconds a square is drawn regardless of the position of the ball. (x,y).
Square is created programmatically, and it is added to the parent element "SquaresList" with name New Game Object.
How can i do, so that the violet field becomes larger, and in the middle of the screen.
I made it so that for every 3 clicks, "SquaresList" increases Scale by 0.25f, and get negative position of the ball. Example:
SquareList.transform.position = new Vector2(-ball.pos.x, -ball.pos.y)
This does not work correctly.
What options can be? (intersections, find the max/min point, math formulas) ?
Hi NoName :) Your method
SquareList.transform.position = new Vector2(-ball.pos.x, -ball.pos.y)
would work perfectly if your object does not inherit other objects and there positions. To fix this make sure that you reset the position of all other game objects that you use as containers.
I created a 1x7 platform. then added a box collider 2D and set the size to 7. you can see in the picture. the platform and box collider are not matching. how can i get it fixed?
X Offset is the easy answer and definitely not a bad one, but maybe not the best one since it could make this problem show up in other areas.
BoxCollider2D by default has its origin at the center of the object ( where the translate tools are showing).
Since the translate tool is at the middle of the platform, the collider should be centered on it as well.
There are several possibilities that I can think of:
The sprites do not have their pivot at the center (If you want it
that way, use Offset to center the box)
The children of the selected object are offset (They should be
shifted over to line up with everything else, unless you need them
this way for some reason)
Create an empty Gameobject - add any sprite objects that you need in there - press the "GameObject" button in the menu and select "Centered on Children" in order for the empty object to be centered properly. This will have to be done each time you add a new object into the bulk. Hope this helps.
i'm trying to do simple game in lazarus, but i'm stuck with one thing that i don't really want to overcomplicate. I have some circles on the screen (pretty small ones, 10pixels diameter) and i want to draw lines between two selected. So i thought i gonna make invisible hitboxes. I took care that two hitboxes doesn't intersect.
And i want to do simple drag and drop. If i drag circle or it's hitbox and drop it on another circle or it's hitbox i want to draw a line between those two circles. And my question is: is there a elegant way of knowing which circle belongs to a hitbox? Or maybe some other nice solution to this problem?
I'm not sure how exactly you have your setup, so the answer is quite generic.
You can start with the following:
Have a function to detect which circle is below cursor - CircleHitTest(X,Y: Integer): Integer;. If there's no circle at given XY - return -1.
Upon MouseDown detect which circle was under a cursor and store it's Id in variable DrawFrom.
Upon MouseUp detect which circle was under a cursor and store it's Id in variable DrawTo
If DrawFrom and DrawTo are two different and valid circles - draw a line between them.