I’m trying to create a pre rendered game in unity. I’m having some issues, which can be seen in the video.
- How would you make it so the cube you move around with cast shadows onto the mesh which is currently hidden. Only make the cube cast shadows onto he underlying geometry. I could just add a shadow sprite under him like they did in the old games but there must be some way of adding real time shadows to him and NPCs?
- He moves around with transform.position and not force, this works fine for keyboard movement but my x box controller don’t like it. I need to make this script use force, but I’m not familiar with how to do that. It’s probably really simple, can someone help me out?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class scr : MonoBehaviour {
bool canPlayerMove = true;
public float speed = 0.0f;
void FixedUpdate()
{
float moveHorizontal = -Input.GetAxisRaw("LeftJoyStickHorizontal");
float moveVertical = Input.GetAxisRaw("LeftJoyStickVertical");
if (canPlayerMove)
{
Vector3 movement = new Vector3(moveVertical, 0.0f, moveHorizontal);
//force stuff?
if (movement != Vector3.zero)
{
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(movement), 0.15F);
}
//add force?
transform.Translate(movement * speed * Time.deltaTime, Space.World);
}
}
}