Question by
jonny038 · Aug 06, 2018 at 03:21 PM ·
jumpingcontrollerspingpong
Merge jumping script with loop movement on x axis
apologies if my question is confusing. Im basically trying to create an object (2D) that moves left and right on the X Axis, and also allow me to jump at the same time. Ive managed to do both separately but not together! below is the looped animation script, if someone could show me how to implement a basic jump controller alongside it, id be very thankful :)
public float delta = 1.5f; // Amount to move left and right from the start point
public float speed = 2.0f;
private Vector3 startPos;
void Start()
{
startPos = transform.position;
}
void Update()
{
Vector3 v = startPos;
v.x += delta * Mathf.Sin(Time.time * speed);
transform.position = v;
}
}
Comment
Your answer
Follow this Question
Related Questions
How to make my controller jump when only on ground and not the walls? 0 Answers
Physics.Raycast not working 1 Answer
Decreasing Gravity Under Certain Conditions Problem 0 Answers
Air Control While Jumping? 1 Answer
jumping for different characters? 0 Answers