Pages 1
Universal Fighting Engine Forum We are no longer using the forum to answer questions due to bot attacks. Please use our discord instead: https://discord.gg/hGMZhF7 |
You are not logged in. Please login or register.
Universal Fighting Engine Forum → 2D Gameplay → Possible to have a teleport move?
@miladzarrin1: Yes.
Here's mine:
https://youtu.be/-qSNrrtfOPU?t=1644
Here's how I did it.
1) Animator, I deleted some frames to create the teleport effect
2) I created a move file for teleportation.
3) I that move, I added particle effect in place of the frames that were invible
4) I changed the x-axis in the move's Self Applied Forces section so that I can set the distance of the teleporation disappearence and reappearance. I also had a sound effect to the teleporation as well.
5) In the move's Invincible Frames section, I enabled Completely Invincible and I enabled Ignore Body Colliders.
@apollo thanks for the detailed explanation.
Is there a way that we can set the teleport to always appear close to the opponent? I want my character to always go right behind the opponent and be able to hit them.
Thank you
Plus when I add self applied forces my character pushes the other character forward. How did you fix this?
Use ignore body colliders to ignore collision between characters
This script might help with teleporting, it can be improved.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UFE3D;
using FPLibrary;
public class NewBehaviourScript : MonoBehaviour
{
[SerializeField]
private string teleportMoveName = "Teleport";
[SerializeField]
private Vector3 teleportPosition;
private void OnEnable()
{
UFE.OnMove += this.OnMove;
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnDisable()
{
UFE.OnMove -= this.OnMove;
}
private void SetPlayerPosition(ControlsScript player, FPVector position, FPVector offset)
{
offset.x *= player.mirror;
player.worldTransform.position = position + offset;
}
private void OnMove(MoveInfo move, ControlsScript player)
{
if (move == null) return;
if (move.moveName == teleportMoveName)
{
SetPlayerPosition(player, player.opControlsScript.worldTransform.position, FPVector.ToFPVector(teleportPosition));
}
}
}
Universal Fighting Engine Forum → 2D Gameplay → Possible to have a teleport move?
Powered by PunBB, supported by Informer Technologies, Inc.