void setRageSpline(Vector2[] splinePoints) { rageSpline = GetComponent<RageSpline>(); rageSpline.ClearPoints(); for (int i=0;i<splinePoints.Length;i++) { rageSpline.AddPoint(0, new Vector3(splinePoints[i].x,splinePoints[i].y,0),new Vector3(0,0,0)); } rageSpline.RefreshMesh(); }
public void CreateNewLandscape() { //transform.position = new Vector3(0f,0f,0f); pointGapWidth = (startX2 - startX) / (float)(pointCount - 1); rageSpline.ClearPoints(); for (int i = 0; i < pointCount; i++) { float x = startX + (float)i * pointGapWidth; curSteepness = steepness + x * 0.00001f; rageSpline.AddPointWorldSpace(i, GetNewLandscapePoint(x), transform.right * pointGapWidth * 0.33f); } rageSpline.SetPoint(0, new Vector3(rageSpline.GetPosition(0).x, 0f, 0f)); rageSpline.SetPoint(1, new Vector3(rageSpline.GetPosition(1).x, 0f, 0f)); rageSpline.RefreshMesh(); }
void setRageSpline(Vector2[] splinePoints) { IRageSpline rageSpline = GetComponent <RageSpline>(); rageSpline.ClearPoints(); for (int i = 0; i < splinePoints.Length; i++) { rageSpline.AddPoint(0, new Vector3(splinePoints[i].x, splinePoints[i].y, 0), new Vector3(0, 0, 0)); } rageSpline.RefreshMesh(); }
void Update() { Vector3 mousePositionWS = Camera.main.ScreenToWorldPoint(Input.mousePosition); mousePositionWS = new Vector3(mousePositionWS.x, mousePositionWS.y, 0f); if (Input.GetMouseButtonDown(0)) // MouseDown { selectNearestItem(mousePositionWS); } if (Input.GetMouseButton(0)) // MouseDrag { updateActiveControlPosition(mousePositionWS); refreshEditorGUI(); rageSpline.RefreshMesh(); } }
void Update() { timeSinceLastShake += Time.deltaTime; // Is it time for a new shake? if (timeSinceLastShake > currentShakeGap) { // Iterate through all the control points for (int index = 0; index < rageSpline.GetPointCount(); index++) { // Randomise a new shake vector Vector3 shakeVector = new Vector3( Random.Range(-0.5f * shakeSizeInNormalSpace.x, 0.5f * shakeSizeInNormalSpace.x), Random.Range(-0.5f * shakeSizeInNormalSpace.y, 0.5f * shakeSizeInNormalSpace.y), 0f); // Get normal and tangent for the control point. We will shake along the normal. Vector3 normal = rageSpline.GetNormal(index); Vector3 tangent = Vector3.Cross(normal, Camera.main.transform.forward); // Set a new position for the control point targetPositions[index] = originalPositions[index] + shakeVector.x * tangent + shakeVector.y * normal; } // When is the next new shake? currentShakeGap = Random.Range(minFrameGap, maxFrameGap); timeSinceLastShake = 0f; } else { // Iterate through all the control points for (int index = 0; index < rageSpline.GetPointCount(); index++) { // Interpolate toward Target positions with Vector3.Lerp() Vector3 currentPosition = rageSpline.GetPosition(index); rageSpline.SetPoint(index, Vector3.Lerp(currentPosition, targetPositions[index], Time.deltaTime * (1f / easing))); } } // Finally refresh the visible mesh rageSpline.RefreshMesh(true, true, false); // Faster version (possible artifacts) //rageSpline.RefreshMesh(false, false, false); }
void OnCollisionEnter(Collision collision) { foreach (ContactPoint contact in collision.contacts) { if (contact.otherCollider.name == "Landscape") { onGround = true; } if (contact.otherCollider.name == "_Rock" && !isGameOver) { isGameOver = true; IRageSpline rageSpline = GetComponent(typeof(RageSpline)) as IRageSpline; rageSpline.SetFillColor1(new Color(1f, 0.2f, 0.2f)); rageSpline.RefreshMesh(); scoreCounter.SendMessage("GameOver"); Invoke("GameOverFinal", 2f); } } onGround = true; }
void Update() { // Iterate through all the control points for (int index = 0; index < rageSpline.GetPointCount(); index++) { // Get the current control point position in localspace coordinates Vector3 oldPosition = rageSpline.GetPosition(index); // Randomise a new shake vector Vector3 shakeVector = new Vector3( Random.Range(-0.5f * shakeSize.x, 0.5f * shakeSize.x), Random.Range(-0.5f * shakeSize.y, 0.5f * shakeSize.y), 0f); // Set a new position for the control point rageSpline.SetPoint(index, oldPosition + shakeVector); } // Finally refresh the visible mesh rageSpline.RefreshMesh(true, true, true); // Faster version (possible artifacts) // rageSpline.RefreshMesh(false, false, false); }