- Home /
Can anyone solve my blink script?
When the local scale.x of my player is positive blink goes forward but in my scenario it goes backward then if i click 2nd turn it goes blink in right position and it normally function but when the local scale x changes then i click my blink at the first time it goes backward then 2nd times goes forward
sorry for my grammar.. i had a few knowledge in english language
this is my scirpt
public void Blink()
{
if (speed > 0 && blink.x < 0)
blink = new Vector3 (blinkDistance, 0, 0);
else
blink = new Vector3 (-blinkDistance, 0, 0);
transform.position += blink;
blink = myTrans.localScale;
blink.x *= -1;
}
void Update () { if (Input.GetKeyDown (KeyCode.O)) { Blink (); } }
Answer by Onk3y · Aug 14, 2017 at 02:56 PM
In fact it is really hard to understand what you're asking for but I think this might work
void Blink()
{
if (blinkVector.x < 0)
blinkVector = new Vector3(blinkDistance, 0, 0);
else
blinkVector = new Vector3(-blinkDistance, 0, 0);
transform.position += blinkVector;
transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
blinkVector = transform.localScale;
}
However using negative scale might srew up the colliders of your gameObjects. Box colliders for example do not support negative scale.
Your answer
![](https://koobas.hobune.stream/wayback/20220612131525im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Oculus Rift Player Camera 0 Answers
how to make character move smoothly is endless runner game 3 Answers
How to make a smooth jump? 2 Answers