I can do it…
To make my character’s movement follow a path, I try to combine movement scripts and follow path scripts together.

Firstly, I assigned a rigidbody to my character.
Using AddForce(Vector3……., FoceMode. impulse) to control movement.

The outcome is too wild apparently .

So I use AddForce(transform…….) instead of AddForce(Vector3……., FoceMode. impulse.
Howerver, it’s not moving at all.

So I say goodbye to rigidbody, using the simplest transform fuction.

Now it’s moving in an acceptable way, but it’s too gentle, like an old lady.

Why Not Try My Own Scripts?

- Create a cube with large box collider, as well as the trunk
- Use trunk to collide with cube’s box collider
- Trigger Conditon
- Character keep moving
Trunk’s script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TrunkController : MonoBehaviour
{
public bool isRemoved = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("ObstacleTrunk"))
{
isRemoved = true;
}
}
}
Character Animation script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GSAnimation : MonoBehaviour
{
private Animator GSAnim;
public TrunkController trunkConScript;
// Start is called before the first frame update
void Start()
{
GSAnim = GetComponent<Animator>();
trunkConScript = GameObject.Find("ObstacleTrunk").GetComponent<TrunkController>();
}
// Update is called once per frame
void Update()
{
if (trunkConScript. isRemoved == true)
{
GSAnim.SetTrigger("AniGS_s2");
}
}
}
To make sure cube would not flying randomly. I want the cube disappear after collide with trunk.
Trunk script with destory function
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TrunkController_Destory : MonoBehaviour
{
public bool isRemoved = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter(Collider other)
{
Destroy(other.gameObject);
Debug.Log("Destroy Cube");
isRemoved = true;
}
}
Now, after my trunk collide the cube’s collider, the cube disapper. Then character start moving forward again.
The easy and tedious work I have to do is adding keyframes one by one for the character in her trails.
