Restore the stable legacy Unity project

This commit is contained in:
Meta Vens 2026-08-10 14:57:50 +01:00
commit 7006a6b0dd
2070 changed files with 180490 additions and 169303 deletions

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SnapToGrid : MonoBehaviour
@ -17,27 +19,31 @@ public class SnapToGrid : MonoBehaviour
public float NormalMultiplier = 100;
public float GravityGradientStep = .01f;
private Vector2 _velocity;
private Rigidbody _body;
// Use this for initialization
void Start () {
_body = GetComponent<Rigidbody>();
}
// Update is called once per frame
void LateUpdate () {
var pos = new Vector2(transform.position.x,transform.position.z);
if (ApplyForces)
{
var force = Gravity.GetForce(pos) * ForceScale;
_velocity += force * Time.deltaTime;
pos += _velocity * Time.deltaTime;
transform.position = new Vector3(pos.x, transform.position.y, pos.y);
}
if(SnapPosition)
transform.position = new Vector3(pos.x, Gravity.GetHeight(pos) + Offset,pos.y);
if (SnapRotation)
{
var normal = Gravity.GetNormal(pos, GravityGradientStep, NormalMultiplier);
var forward = Vector3.Cross(transform.right, normal);
var forward = Vector3.Cross(transform.right, normal);
transform.rotation = Quaternion.LookRotation(forward, normal);
}
if (ApplyForces)
{
//var currentVelocity = _body.velocity;
var force = Gravity.GetForce(pos) * ForceScale;
_body.AddForce(force.x,0,force.y,ForceMode.Acceleration);
}
}
}