Dear friends I would like to make game like following:
This is going to be similar so I want to work on basic mechanics and crafting abilities, particles and time of day. I would like to use standard render pipeline for this one. More to follow when friend puts together some graphics.
Thanks
First quick time of day.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class rotate : MonoBehaviour {
public float speed = 50.0f;
Vector3 angle;
float rotation = 0f;
public enum Axis
{
X,
Y,
Z
}
public Axis axis = Axis.X;
public bool direction = true;
void Start()
{
angle = transform.localEulerAngles;
}
void Update()
{
switch(axis)
{
case Axis.X:
transform.localEulerAngles = new Vector3(Rotation(), angle.y, angle.z);
break;
case Axis.Y:
transform.localEulerAngles = new Vector3(angle.x, Rotation(), angle.z);
break;
case Axis.Z:
transform.localEulerAngles = new Vector3(angle.x, angle.y, Rotation());
break;
}
}
float Rotation()
{
rotation += speed * Time.deltaTime;
if (rotation >= 360f)
rotation -= 360f; // this will keep it to a value of 0 to 359.99...
return direction ? rotation : -rotation;
}
}
Movement
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class targetMove : MonoBehaviour
{
public float transitionDuration = 2.5f;
Vector3 newPosition;
void Start () {
newPosition = transform.position;
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
{
newPosition = hit.point;
//transform.position = newPosition;
StartCoroutine(Transition());
//transform.position = Vector3.Lerp(transform.position, newPosition, 5.0f * Time.deltaTime);
}
}
}
IEnumerator Transition()
{
float t = 0.0f;
Vector3 startingPos = transform.position;
while (t < 1.0f)
{
t += Time.deltaTime * (Time.timeScale/transitionDuration);
transform.position = Vector3.Lerp(startingPos, newPosition, t);
yield return 0;
}
}
}
Dear friend, some big news. I stumbled on much better tutorial for movement here by someone called ‘brackeys.’
Will try to work into game today.