- Home /
Question by
AzogD · Aug 09, 2018 at 11:33 AM ·
javascriptmovement scriptobjectsmove an objectmathf
Trying to move an object between two points
Can you please help me arrange this correctly...
#pragma strict
public var speed = 5f;
function Start () {
}
function Update () {
transform.position.x = (Mathf.PingPong (Time.time * speed, 5.1, 0.9));
}
Comment
Answer by brendanperry05 · Aug 09, 2018 at 12:20 PM
Try this as a starting point:
transform.position = new Vector3(.9 + Mathf.PingPong(Time.time * speed, 4.2), transform.position.y, transform.position.z);
Answer by AzogD · Aug 09, 2018 at 01:20 PM
Now the object goes between 0 and 5.1 Not 0.9 and 5.1
If it works well could you accept my answer as correct? It helps me out. Glad I could help
Your answer
![](https://koobas.hobune.stream/wayback/20220612172507im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
I need help with a CharacterMotor script error in Unity5. This is formatted in Javascript. 0 Answers
I can't make my ball jump using distToGround and Physics.Raycast 0 Answers
How do I create and loop through a completely generic list in javascript? 1 Answer
Slowly move a GameObject on 1 axis, then destroy it. 1 Answer