#alright thanks X

1 messages · Page 1 of 1 (latest)

spare river
long ridge
#

should I explain further in detail what I'm going for so get the idea?

spare river
#

i think i understnad

long ridge
#

basically the same as little big planet

spare river
#

you're just making an emerge from (location) animation

#

the simplest way to do it would be w/ DoTween or a tweening library

#

but if u want animation its gonna take a bit of a hack

long ridge
spare river
#

you got a few problems

  • if you want the animation re-useable you can't animate the OUTER gameobject
    (this locks it to teh animation in world-coordinates).. meaning u wont be able to re-use it anywhere else. unless u had an animation for each portal
#
  • next problem is w/ the player *you dont want it always inside another gameobject if it doesnt need to be.. (so this is where we'd have to parent and unparent it before and after each animation)
#
  • lastly.. the movement and camera are taking ur inputs... (if we animate we'd want to disable that for that brief period that we're animating)
spare river
#

thing.DoMove()
thing.DoScale()
thing.DoColor() etc etc.. not sure those are the exact methods..

#

but its basically just Lerping and Slerping things here and there

long ridge
#

alright thanks I will have a further look into it

spare river
#

im just gonna do 2 positions with (1) animation

#

then with the example i show u can use it over and over

#

so far so good lol

spare river
#

to have an inner gameobject that we could move to different portals.. and then attach the player to the inner gameobject that would do the emerge thing..

#

it works but it doesn't... i've had trouble with my camera script in the past and it seems the same things happening now

#

close but no cigar.. this is what ive been meaning tho..
when we go into the trigger we can move the main teleporter object anywhere we want..
then the code parents the controller to the child (the thing animating)..

#

and u can disable and enable it and re-use it as many times as u want... (i think if i had a better camera controller this would work as it is.. but right now my rotations are getting all messed up when i teleport (and do a 180)

#
using UnityEngine;
using SPWN;
using System.Collections;

public class TeleportTrigger : MonoBehaviour
{
    public GameObject Teleporter; // this object is the holder of the animation
    public GameObject TeleporterChild; // the object that actually animates

    public Transform teleportPosition; // transform of where to move the teleporter

    public GameObject playerMainGO; // the player gameObject
    public SpawnCampControllerLite SpawnCampControllerLite; // to disable movement
    public ControllerCamera ControllerCamera; // to disable camera movement

    public float animationTimer = 1; // we need to know how long the animation is so we can unparent the the controller afterwards


    private void OnTriggerEnter(Collider other)
    {
        if(other.CompareTag("Player"))
        {
            // move teleporter animation's (root) to the correct portal
            Teleporter.transform.position = teleportPosition.position;
            Teleporter.transform.rotation = teleportPosition.rotation;

            // disable movement and camera movement so we can move our player and so that our animations move it
          

            // now we need to make player a child of the `Inner` gameobjet (the one that animates)
            playerMainGO.transform.parent = TeleporterChild.transform;

            // and set our position and rotation to match
            playerMainGO.transform.position = TeleporterChild.transform.position;
            playerMainGO.transform.forward = TeleporterChild.transform.forward;

            SpawnCampControllerLite.canControl = false;
            ControllerCamera.enabled = false;

            // now we've moved the player to the child and we've set its postion and rotation to match it.. 
            // we'll enable the Teleporter now so it can animate
            StartCoroutine(WaitForAnimationAndDisable());
        }
    }

    IEnumerator WaitForAnimationAndDisable()
    {
        Debug.Log("We Should have ENABLED The Teleporter Object.");
        Teleporter.SetActive(true);

        yield return new WaitForSeconds(animationTimer);

        //unparent player
        playerMainGO.transform.parent = null;

        //restore controls
        SpawnCampControllerLite.canControl = true;
        ControllerCamera.enabled = true;

        //disable teleporter to re-use later
        Teleporter.SetActive(false);
    }
}
``` no beuno tho
#

imma try again in a bit

#

i honestly think its my camera code..

#

and it may work with yours

#

b/c if i dont rotate the player to match the portal's rotation it does work lol

long ridge
#

thank you so much, So in a nut shell I can just have 1 animation and when the player dies the player teleports back to the spawn box and replays that animation correct?

spare river
#

the way i have it set up
you have 1 object (the main teleporter)
it animates a child object (that does the actual moving)

soo.. anytime u want.. u can grab the OUtter object (and align it to the portal)
then parent the controller to that child that moves.. (it'll always move according to how that outter is rotated)

#

so i just
Move the teleporter..
Parent the controller to the child
and then enable the entire gameobject

#

it automatically animates the player since it got parented to that child..

#

once the animation is over u can unparent it.. disable the teleporter.. and just wait until u need it again

#

then its rinse and repeate.. (move it to the new position u want).. parent the controller to the child, enable it.. let it animat.. etc

long ridge
#

I see this is way simpler than I thought lol

spare river
#

got a tooth-ache today.. its hard for me to explain what im thinkin in my head 😄

long ridge
#

thanks again !!!! ❤❤

spare river
#

good luck 👍

spare river
#

imma try to fix my camera code now that i see its really bad lol

long ridge
#

btw if you enable this you can enter play mode faster

spare river
#

ya, i always forget that i turned it off tho 😄

#

that was a burner project anyway.. i duplicated my original one so i could code w/o breaking any of my stuff

long ridge
spare river
#

you have to select the child object when u animate

#

u can click "Add" or Create new animation on that root object.. but then select the child when adding keyframes..

long ridge
#

do I select the actual player not inner?

spare river
#

when u hit record u then select the child and move it..

#

It tells exactly which object ur keyframing

#

Inner: Position, Rotation, Etc

long ridge
#

like that?

spare river
#

ya, u can test..

#

if u now select the Inner gameobject and press preview or play in the animator

#

you'll see it's gizmo being animated

long ridge
#

is still does it

#

If I do it this way it works hold on...

spare river
long ridge
spare river
#

yea but what u did just there ^ was lock up ur player

#

by adding keyframes to it...

long ridge
spare river
#

the whole point of the empty containers. was to animate them instead.. w/o having to put an animation o n the player at all

#

then if u parent it to it.. it'll just follow along..

long ridge
spare river
#

(as long as ur movement code isn't fighting it*

#

imma try out using DoTween instead.. as this is "simple" in theory.. but can get complicated once its all set up.. and having to move around it and then attaching the player.. and blabla

#

might be able to just teleport the player and then play a simple Tween for a second..

#

that'd be hella lot easier (in terms of work)

long ridge
#

ok I will download dotween then 👍

spare river
#

have u got it working w/o animation?

#

like just teleporting the player and having it face the right direction?

long ridge
spare river
#

i'd test that and make sure thats working first 😄

#

no i just mean... the teleport code.. no animation at all

long ridge
#

ohh I havent done the teleport code yet just wanted to get the animation part out of the way first

spare river
#

b/c if thats working it shouldnt be too bad to add the tween to it.. (if thats all working)

spare river
#

so with a tween setup its way simpler

#

`- Disable player control (so they don’t interfere with movement).

  • Teleport instantly to the target position.
  • Apply a forward tween (push effect).
  • Re-enable controls once the tween finishes.`
long ridge
#

Hey just watched some videos about dotween and its pretty cool. Should I remove the animations and the outer and inner game objects? Since im animating it by code, or will it just lock the player?

spare river
#

its great for animating little things like u were describing figured it be useful in other areas too..

#

if u dont need the old way delete em 👍

#

unless ur still using the containers for ur dotween or w/e
if not i'd remove em.. no need for extra stuff u dont need ;D

long ridge
#

got it, So could I use the tween animation to play for different checkpoints?

spare river
#

sure u could..

#

since its a script instead of an animator.. u can just plug in the values u want for each place u need to use it

long ridge
#

Thanks helpful as always ❤️👍

long ridge
#

I have done some thinking and this is how I'm going to do it what do you think? Basically the player spawns where the respawn point is and the checkpoint saves the player spawn point so in the inspector when the player enters the box collider it will add the spawn point so the player will spawn there. Kill area teleports the player back to the spawn point and rinse and repeat you get the idea. Is this a good way to do this? just needed some one else's feedback.

spare river
#

i can't say if its good or not.. but what really matters is does it work for you?
do you understand it? and can you refactor it easily?

long ridge
#

I made it so it's very easy to set up and reusable so I can have loads of check points 😁

#

Thanks for the help DOTWEEN IS AWESOME!!

spare river
#

innit it..

#

i've recently removed it from my assets tho..

#

i blame it for breaking one of my really good projects

#

i think the installation messed up the update loop or timing..

#

or something i did possibly.. idk..

#

my friends recommended me to use PrimeTween

#

apparently its better for performance

long ridge
#

Is primetween better than DOTWEEN?

spare river
#

DoTween is absolutely fine to use tho..

#

yea.. from what ive looked at.. its better

#

it doesn't make as much Garbage that the garbage collector has to pick up

#

i actually havent swapped over to it yet.. i just removed my tweens for now.. and do my own tweening in coroutines for now

#

problem w/ DoTween is that unless you manage it / use it specifically the way it needs to be used you'll end up with more garbage collection having to happen.. but that may not even be a problem for a smaller scale game.

#

you may want to read up on it yourself.. but im only switching b/c i publish assets and stuff and I have to keep Third-party Unity Store assets out of the project anyway..

long ridge
spare river
#

and primetween is a github

#

ahh sht i cant use this either..

#

i'll have to stick to my custom coroutines

#

but i'll still use it for my game-stuff

spare river
#

and i think from what ive looked at it works almost the same as DoTween

#

some of the old-head (pro-level coders was talkin about how its better) but tbh i didn't understand alot of it

#

less garbage.. (and i dont think u have to install it like u do with DoTween)

long ridge
#

Alright thanks for that I'm going to have a further look at prime tween

spare river
#

same.. i'll prolly install it here in a min

spare river
long ridge
spare river
long ridge
#

Now that I've finished this I can finally start level design 🤩

long ridge
spare river
#

nah its an asset i'll be givin away

#

and using in my YT tutorials

#

i wont have to start w/ a stupid little plane

#

and since the viewr's can download it for free.. its a nice starting point

long ridge
spare river
#

instead of bad code, quick code, copy and paste code..

#

and since i can make info-graphics and stuff pretty well b.c i came from being a graphic artist to being a game dev..

#

i think they gonna be much better production quality