- Home /
How can i change a gameobject scale to only one direction ?
void Update()
{
if (DetectPlayer.touched == true)
{
if (raiseAmount < raiseTotal)
{
float raiseThisFrame = speed * Time.deltaTime;
if (raiseAmount + raiseThisFrame > raiseTotal)
{
raiseThisFrame = raiseTotal - raiseAmount;
}
raiseAmount += raiseThisFrame;
gameObjectToRaise.transform.localScale += new Vector3(raiseThisFrame, raiseThisFrame, 0);
cubes[0].transform.localScale += new Vector3(raiseThisFrame, raiseThisFrame, 0);
cubes[0].transform.position += Vector3.left * (speed / 2) * Time.deltaTime;
}
else
{
raised = true;
}
}
}
When i'm changing the cube[0] scale it will change it to front and to back. But i want it to scale it only to the front direction. I mean to scale the axis x but not to stretch it like back and front only to the front.
Please specify which of the following behaviors you want:
The cube is stretched along one axis as usual but changes it's position so it's $$anonymous$$imum bounds position doesn't change
Only the cube's left and right faces stretch, and they move along with the front face, while the back face stays in place.
I think the first behavior.
I mean left is what i call front. Since i rotate the cube by 90 degrees it looks front but i mean left stretch only. And not left and right. You right. I should say left and right. So only left stretch.
Your answer
Follow this Question
Related Questions
Why when creating new animator controller for the character the character is not walking right ? 0 Answers
How can i Instantiate on the terrain from left to right ? 0 Answers
Why the tile map scripts take almost all the cpu usage ? cpu usage is getting to 99% at times 1 Answer
How can i rotate object by pressing on key R and keep object facing to me my self ? 0 Answers
Why it;s never getting to the OnMouseDown function when clicking with the mouse ? 1 Answer