I moved the table away and also made the character smaller but it seems I can’t step over this thicker dark line where both room-modules hit each other. I slowly think that the reason may be the locomotion script. I tried to understand it but so far I don’t. It was delivered by the author of the asset:
The farmer has a script called LocomotionPlayer:
/// <summary>
///
/// </summary>
using UnityEngine;
using System;
using System.Collections;
[RequireComponent(typeof(Animator))]
//Name of class must be name of file as well
public class LocomotionPlayer : MonoBehaviour
{
public GameObject currentHorse;
public GameObject currentDoor;
public bool atDoor;
private Transform mountPoint;
protected Animator animator;
private bool _jump;//jump button press detection
private bool _getOnHorse;
public bool ridingHorse;
private float speed = 0;
private float direction = 0;
private Locomotion locomotion = null;
// Use this for initialization
void Start ()
{
animator = GetComponent<Animator>();
locomotion = new Locomotion(animator);
}
void Update ()
{
if (animator && Camera.main)
{
//Debug.Log(Camera.main.ToString());
_jump = Input.GetButton("Jump") ? true : false;//check if jump button was pressed
JoystickToEvents.Do(transform, Camera.main.transform, ref speed, ref direction);
locomotion.Do(speed, direction);
}
//DOOR CONTROL
if (Input.GetKeyDown(KeyCode.E))
{
if (atDoor && currentDoor != null)
{
Transform newPosition = currentDoor.GetComponent<DoorControl>().teleportTo;
Camera newCamera = currentDoor.GetComponent<DoorControl>().camToEnable;
Camera offCamera = currentDoor.GetComponent<DoorControl>().camToDisable;
this.transform.position = newPosition.position;
if (newCamera != null)
{
newCamera.enabled = true;
}
else
{
return;
}
if (offCamera != null)
{
offCamera.enabled = false;
}
else
{
return;
}
}
else
{
return;
}
}
Vector3 ahead = transform.forward;
Vector3 rayStart = new Vector3(this.transform.position.x, this.transform.position.y + 1f, this.transform.position.z);
Ray ray = new Ray(rayStart, ahead);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 3f))
{
if (hit.transform.gameObject.name == ("horse"))
{
currentHorse = hit.transform.gameObject;
mountPoint = currentHorse.transform.Find("horseMountPoint");
if (Input.GetKey(KeyCode.E))
{
this.transform.position = mountPoint.position;
this.transform.rotation = mountPoint.rotation;
ridingHorse = true;
StartCoroutine(getOnHorse());
_getOnHorse = true;
}
}
if (hit.transform.gameObject.name == ("dog"))
{
if (Input.GetKey(KeyCode.E))
{
hit.transform.gameObject.GetComponent<DogControl>().idling = false;
hit.transform.gameObject.GetComponent<AnimalSounds>().PlaySound();
}
}
}
if (ridingHorse)
{
if (Input.GetKey(KeyCode.F))
{
_getOnHorse = false;
ridingHorse = false;
this.animator.applyRootMotion = true;
currentHorse.GetComponent<HorseControl>().canControll = false;
this.transform.parent = null;
StartCoroutine(getOffHorse());
}
}
}
void FixedUpdate ()
{
animator.SetBool("Jump", _jump);
animator.SetBool("OnHorse", _getOnHorse);
}
IEnumerator getOnHorse ()
{
yield return new WaitForSeconds(1.6f);
this.animator.applyRootMotion = false;
currentHorse.GetComponent<HorseControl>().canControll = true;
this.transform.parent = currentHorse.GetComponent<HorseControl>().backBone.transform;
this.transform.position = currentHorse.GetComponent<HorseControl>().backBone.transform.position;
this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y + 0.1f, this.transform.position.z);
this.transform.rotation = currentHorse.GetComponent<HorseControl>().horseSaddle.transform.rotation;
}
IEnumerator getOffHorse ()
{
yield return new WaitForSeconds(1.6f);
this.transform.position = Vector3.Slerp(this.transform.position, mountPoint.position, 10 * Time.deltaTime);
this.transform.rotation = Quaternion.Slerp(transform.rotation, mountPoint.rotation, 10 * Time.deltaTime);
}
void OnTriggerEnter (Collider trigg)
{
if (trigg.gameObject.tag == "doorway")
{
atDoor = true;
currentDoor = trigg.gameObject;
}
else
{
//TODO: Farmer kommt nicht aus der Ecke vom Haus raus wo die Truhe ist
Debug.Log("Hit: " + trigg.gameObject.ToString());
}
}
void OnTriggerExit (Collider trigg)
{
if (trigg.gameObject.tag == "doorway")
{
atDoor = false;
currentDoor = null;
}
}
}
using UnityEngine;
using System.Collections;
public class JoystickToEvents : MonoBehaviour
{
public static void Do (Transform root, Transform camera, ref float speed, ref float direction)
{
Vector3 rootDirection = root.forward;
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
Vector3 stickDirection = new Vector3(horizontal, 0, vertical);
// Get camera rotation.
Vector3 CameraDirection = camera.forward;
CameraDirection.y = 0.0f; // kill Y
Quaternion referentialShift = Quaternion.FromToRotation(Vector3.forward, CameraDirection);
// Convert joystick input in Worldspace coordinates
Vector3 moveDirection = referentialShift * stickDirection;
Vector2 speedVec = new Vector2(horizontal, vertical);
speed = Mathf.Clamp(speedVec.magnitude, 0, 2);
if (speed > 0.01f) // dead zone
{
Vector3 axis = Vector3.Cross(rootDirection, moveDirection);
direction = Vector3.Angle(rootDirection, moveDirection) * (axis.y < 0 ? -0.5f : 0.5f);
}
else
{
direction = 0.0f;
}
}
}
using UnityEngine;
using System.Collections;
public class Locomotion
{
private Animator m_Animator = null;
private int m_SpeedId = 0;
private int m_AgularSpeedId = 0;
private int m_DirectionId = 0;
public float m_SpeedDampTime = 0.5f;
public float m_AnguarSpeedDampTime = 0.25f;
public float m_DirectionResponseTime = 0.1f;
public Locomotion(Animator animator)
{
m_Animator = animator;
m_SpeedId = Animator.StringToHash("Speed");
m_AgularSpeedId = Animator.StringToHash("AngularSpeed");
m_DirectionId = Animator.StringToHash("Direction");
}
public void Do(float speed, float direction)
{
AnimatorStateInfo state = m_Animator.GetCurrentAnimatorStateInfo(0);
bool inTransition = m_Animator.IsInTransition(0);
bool inIdle = state.IsName("Locomotion.Idle");
bool inTurn = state.IsName("Locomotion.TurnOnSpot") || state.IsName("Locomotion.PlantNTurnLeft") || state.IsName("Locomotion.PlantNTurnRight");
bool inWalkRun = state.IsName("Locomotion.WalkRun");
float speedDampTime = inIdle ? 0 : m_SpeedDampTime;
float angularSpeedDampTime = inWalkRun || inTransition ? m_AnguarSpeedDampTime : 0;
float directionDampTime = inTurn || inTransition ? 1000000 : 0;
float angularSpeed = direction / m_DirectionResponseTime;
m_Animator.SetFloat(m_SpeedId, speed, speedDampTime, Time.deltaTime);
m_Animator.SetFloat(m_AgularSpeedId, angularSpeed, angularSpeedDampTime, Time.deltaTime);
m_Animator.SetFloat(m_DirectionId, direction, directionDampTime, Time.deltaTime);
}
}
I understand only parts of it but in the rest of the game (outside the house) it works without problems.