- Home /
scale based on position(help)
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class fogomov : MonoBehaviour { private Vector3 PosA;
private Vector3 PosB;
private Vector3 nexp;
[SerializeField]
private float speed;
[SerializeField]
private Transform childtransform;
[SerializeField]
private Transform transformB;
// Use this for initialization
void Start () {
PosA = childtransform.localPosition;
PosB = transformB.localPosition;
nexp = PosB;
}
// Update is called once per frame
void Update () {
Move();
}
private void Move()
{
childtransform.localPosition = Vector3.MoveTowards(childtransform.localPosition, nexp, speed * Time.deltaTime);
if (Vector3.Distance(childtransform.localPosition, nexp) <= 0.01)
{
Changedestination();
}
}
private void Changedestination()
{
nexp = nexp != PosA ? PosA : PosB;
}
} i got this script to move an object but I wanted it every time the object arrives at a destination it turns to the contrary someone can help me I can not do
I am unclear what you mean by "object arrives at a destination it turns to the contrary"
And if you could fix your code segment/grammar that would be great.
Answer by viber-tron · May 08, 2018 at 09:28 AM
Sorry i dont speak english very well , this is a scrict for a moving platform and i wanted to turn the sprite to right or left depending the position PosA, PosB its better now?
Your answer
Follow this Question
Related Questions
Create an animation with variables? 1 Answer
How do I make a player shoot right and left 2D platformer firing left and right, help! 1 Answer
What is the reasoning of multiplying by Time.deltaTime 1 Answer
Adding a value to transform.position.y runs very untrusted 0 Answers
Changing transform.localScale of a prefab in the script not working. Help pls! 1 Answer