Jump to content

Animators not working


Recommended Posts

TL;DR

The orange light on the far right should light up, but it does not. (in the video)

In order to make independent lights, I used thin layers of orange emissive material hidden under those chevrons (the v-shape objects around the ring). To turn on the light, I simply animate that orange-light-object upwards out of the body to become visible.

It works for the top(12 o'clock) chevron light, and also the first chevron on the right(2 o'clock), but not any others. The 2nd chevron on the right (3 o'clock) is supposed to light up after the 1st but just doesn't. They would all stay on as new lights turn on in sequence, going clockwise until everything is lit up.

I had no issues with the previous animations (spinning ring; top moving chevron; event horizon; unstable vortex;), but these extra lights just don't function. The 2nd-6th lights are all the same as the 1st light(2 o'clock), and each one's animation has a unique name to reference it. Counting the amount of animations in Blender shows that the first 8 animations are fine...the 9th and onwards are not responding (unity does not limit the count of animators, does it? :confused:)

Github repo:

https://github.com/Blaarkies/ksp-mod-stargate/blob/8866e6c052c9b13c936ad8ad95773ebe7c9657e8/Src/Utilities/StargateDialer.cs#L94

 

Please pay no attention to the horrendous textures...I learned blender through 3d printing, I never had to work with textures for that :blush:

 

 

 

Edited by Blaarkies
Fix video
Link to comment
Share on other sites

Not watching your video but If I understand what you have written, You are using a KSP emissive shader to light up chevrons that are hidden under the skin of your model using this module

    MODULE
    {
        name = ModuleColorChanger
        shaderProperty = _EmissiveColor
        animRate = 0.8
        animState = false
        useRate = true
        toggleInEditor = true
        toggleInFlight = true
        toggleInFlight = true
        unfocusedRange = 5
        toggleName = Toggle Lights
        eventOnName = Lights On
        eventOffName = Lights Off
        toggleAction = True
        defaultActionGroup = Light
        redCurve
        {
            key = 0 0 0 3
            key = 1 1 0 0
        }
        greenCurve
        {
            key = 0 0 0 1
            key = 1 1 1 0
        }
        blueCurve
        {
            key = 0 0 0 0
            key = 1 0.7 1.5 0
        }
        alphaCurve
        {
            key = 0 1
        }
    }

You then are using a separate module like this example for each of the chevrons to be pushed up from under the skin.

    MODULE
    {
        name = ModuleAnimateGeneric
        animationName = LandingGear
        startEventGUIName = Gear Up
        endEventGUIName = Gear Down
        actionGUIName = Landing Gear
        defaultActionGroup = Gear
        layer = 1
    }

If this is correct and each chevron has it's own "animationName =" that is unique to it. Are you remembering to give each ModuleAnimateGeneric module a unique "layer =" so that they don't interfere with each others operation?

Everything that is considered animated in a model and uses different animation names needs to have a different "layer =" It doesn't match anything in blender and there is no correct order, it just has to be a different number to any other animation in the config.

If they are not animating in blender itself then that it is a different problem, I have never tried to animate that many different things on the same model myself.

Link to comment
Share on other sites

@ColdJ Fixed the video. Sorry I know random links look sketchy

Im not using the CFG modules to make this work, but i might try it as an alternative, maybe it's a workaround. How would I trigger any of the ModuleAnimateGeneric from c# code using this method? The animations in my model are part of a long running sequence where the user only clicks once to start it. (it does ring a bell for me as a property on Part Class Reference)

But yes I do use a unique layer id (in c# code) for each animation on the model, it is the same system used for the other animations that function properly. In Blender all the animations work fine. I export using the .mu plugin, but I see some devs use Unity as the final export step.

If i could find a way to make such lights turn on/off using only the ModuleColorChanger you mentioned, i wouldn't even need the movement animation, this would be great! I'll give that a shot soon and see if i can get it going.

Edited by Blaarkies
Link to comment
Share on other sites

@Blaarkies

Saw, the video now, A Stargate, very cool. I don't do coding myself so can't help you there. The other thread might be helpful for that.

https://forum.kerbalspaceprogram.com/index.php?/forum/29-c-plugin-development-help-and-support/

In my method I am not sure you could get that lovely lock in sound per chevron that you have, more just one long sound effect for the entire thing. The sequence itself could be done in one animation if it isn't variable. The colour change module is more an all on at once thing so you would still need the animation to hide it and show it I think. It is one of the most complex things I have seen in KSP so if one of the coding experts in the other thread can help you then that is probably better for you. Otherwise I think 1 long animation that includes rotation, location and resize in the keyframes, using resize to bring the lit chevrons out of hiding under the skin on each chevron activation.

Good Luck.

Link to comment
Share on other sites

12 hours ago, VenomCell said:

I'm still a noob with modding but I'm a big fan of Stargate and this is awesome lol. I am good with Photoshop and somewhat competent unwrapping models so I'd be more than happy to help create a UV for you.

That would be awesome, more than welcome to contribute! :)

You can have a look at the repo here,  I have some readmes setup there to explain the plan. If you are not familiar with Git, I would be super happy to give you a walkthrough, just message me and we can setup something. Else you can always use the download as zip to get the project files

Link to comment
Share on other sites

  • 1 month later...

@Blaarkies If you manually control when the chevrons move instead of using the stock animation part module, have you considered controlling the emissive texture on the chevron’s model as well? Something like:

            Transform target = this.part.FindModelTransform(textureTransformName);
            rendererMaterial = target.GetComponent<Renderer>();
                rendererMaterial.material.SetColor("_EmissiveColor", new Color(1, 1, 1, 1));

I hope that helps. :)

Link to comment
Share on other sites

3 hours ago, Angel-125 said:

@Blaarkies If you manually control when the chevrons move instead of using the stock animation part module, have you considered controlling the emissive texture on the chevron’s model as well? Something like:

This could be the solution, thanks! Currently they all use the same material (the chevron light emissive) and i didn't think it was possible to "customize" the lighting color on each one (they are all separate objects, for the animation of course) 

I have been distracted with a separate project in the meanwhile, and last I was busy fixing the subject rotation/velocity as it passes the gate. I've been meaning to come back to this soon to make a beta release version

Btw great job on the Blueshift: Kerbal FTL mod extension, that model looks excellent!

Edited by Blaarkies
Link to comment
Share on other sites

1 hour ago, Blaarkies said:

This could be the solution, thanks! Currently they all use the same material (the chevron light emissive) and i didn't think it was possible to "customize" the lighting color on each one (they are all separate objects, for the animation of course) 

I have been distracted with a separate project in the meanwhile, and last I was busy fixing the subject rotation/velocity as it passes the gate. I've been meaning to come back to this soon to make a beta release version

Btw great job on the Blueshift: Kerbal FTL mod extension, that model looks excellent!

Thanks! :) Regarding the chevron material, since the chevrons are individual meshes, then you can definitely set their material's emissive. Are you going to make a DHD too? I could see individual buttons light up as you press them, and it sends the coordinates to the gate. You can monitor mouse clicks on the button's collider (in Unity, set isTrigger to true), so the DHD will know what button is pressed. Something like this to watch the click event, and then this to set up the button. Imagine that the stargate "vessel" has the gate part, a platform part, and a DHD. If the gate and DHD pair up, you could generate a random gate address and, to be nice, let the DHD list all the gate addresses. Then the player would just need to tap in the address...

Link to comment
Share on other sites

 

1 hour ago, Angel-125 said:

You can monitor mouse clicks on the button's collider (in Unity, set isTrigger to true), so the DHD will know what button is pressed.

That would be so cool, i didn't even think of on-hover mouse buttons:o. Currently in the video you might see a DHD button on the PAW menu, which dials the gate using a much faster method (without gate spinning)...it works great for quick debugging :D The idea i had in mind was that, if a DHD part is found on the same vessel, the stargate part's PAW menu will have the DHD option available, which when called, will trigger the lights on the DHD part.

I had lots of trouble getting the actual teleportation to work though. It is easy over short distances, just set the the new location. Even teleporting to a gate in orbit right above the KSC worked, but when I teleport long distances the vessels starts to jitter (looks like the floating point precision issues that Squad faced in the early versions of KSP). The other issue is teleporting to a gate behind the planet (or mountain), it is like Unity still tries to do collision detection and "moves" the vessel to the new location really quickly. Have you ran into any of these?

Link to comment
Share on other sites

1 hour ago, Blaarkies said:

 

That would be so cool, i didn't even think of on-hover mouse buttons:o. Currently in the video you might see a DHD button on the PAW menu, which dials the gate using a much faster method (without gate spinning)...it works great for quick debugging :D The idea i had in mind was that, if a DHD part is found on the same vessel, the stargate part's PAW menu will have the DHD option available, which when called, will trigger the lights on the DHD part.

I had lots of trouble getting the actual teleportation to work though. It is easy over short distances, just set the the new location. Even teleporting to a gate in orbit right above the KSC worked, but when I teleport long distances the vessels starts to jitter (looks like the floating point precision issues that Squad faced in the early versions of KSP). The other issue is teleporting to a gate behind the planet (or mountain), it is like Unity still tries to do collision detection and "moves" the vessel to the new location really quickly. Have you ran into any of these?

I haven't run into those issues. What I do is this:

            // If the destination is in space then rendezvous with its orbit. Otherwise, land next to it.
            // We can use size here because, while inaccurate, it is overestimated, and we just want to get in the vicinity
            vesselToTeleport.UpdateVesselSize();
            Vector3 size = vesselToTeleport.vesselSize;
            if (BlueshiftScenario.shared.IsInSpace(destinationVessel))
            {
                Vector3 position = destinationVessel.transform.up.normalized * (rendezvousDistance + size.y);
                FlightGlobals.fetch.SetShipOrbitRendezvous(destinationVessel, position, Vector3d.zero);
            }

            // Land the vessel next to the jumpgate.
            else if (BlueshiftScenario.shared.IsLandedOrSplashed(destinationVessel))
            {
                // Get destination's location.
                double inclination = destinationVessel.srfRelRotation.Pitch();
                double heading = destinationVessel.srfRelRotation.Yaw();
                Vector3d worldPos = destinationVessel.GetWorldPos3D();

                // Now, calculate how far to offset the teleporting vessel relative to the destination
                Transform refTransform = destinationVessel.ReferenceTransform;
                double distance = Math.Round(Mathf.Max(size.x, size.y, size.z), 2) / 2 + 5.0;
                Vector3 translateVector = refTransform.up * (float)distance;
                Vector3d offsetPosition = worldPos + translateVector;

                // Get the offset latitude and longitute
                Vector2d latLong = destinationVessel.mainBody.GetLatitudeAndLongitude(offsetPosition);
                double latitude = latLong.x;
                double longitude = latLong.y;

                // Off we go
                FlightGlobals.fetch.SetVesselPosition(destinationVessel.mainBody.flightGlobalsIndex, latitude, longitude, distance, inclination, heading, true, true);
                FloatingOrigin.ResetTerrainShaderOffset();
            }

My code is all GPLV3, so take what you need. :)

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...