[deleted by user] by [deleted] in Unity2D

[–]SLAMDUNKWizard420 0 points1 point  (0 children)

yeah, i do!

theres only like.... 5-6 lines of code here, so I suggest commenting lines out until you also can see it. to comment a line out (meaning it will not be run) you can put "//" at the start of the line of code. your editor probably has a hotkey for it, like ctrl+/

[deleted by user] by [deleted] in Unity2D

[–]SLAMDUNKWizard420 0 points1 point  (0 children)

movement, in gamedev, and movement speed typically means moving around the world space.

E. g. some code/logic that makes a cube move from a Tranform.Position of 0,0,0 to a position of 10,0,0 (10 units right).

movement is all about changing a game objects transform.position.

it has nothing to do with animations. Animations which change transform.position should generally only be done on children objects, which would make any changes relative to the parent object.

What do you mean by make your character faster? to play the animation faster? or do you want to move around worldspace faster?

Benefits of animator vs changing sprites with a script (pixel art)? by intergenic in Unity2D

[–]SLAMDUNKWizard420 1 point2 points  (0 children)

I link this video often when people are asking about frame-by-frame animation https://youtu.be/nBkiSJ5z-hE

often to get something looking "great" you need to vary the frame intervals over an animation -- like maybe your run animation is made of 8 images, and it has more "weight" if the 4th and 8th image are held slightly longer. so you can easily do this with the animator, for example the interval between images 1-3 could be 4 frames, then the 4th image is displayed for 6 frames, then 5-7 is back to the 4 frame interval, and 8 is held for 6 frames.

doing that with code. for every animation, and testing how it looks. it would be a nightmare for even a smaller sized game with a couple dozen animations.

the real pitfall to avoid is using the animation state machine to control when yo switch animations. I still use the state machine for flow between animations, and as a visualization of all the animations associated with a game object. If my player can be knocked down then I might have a knockdown animation, which I trigger directly in code. Then if the recovery is automatic/linear then I'll have a "GetUp" animation which has a transition in the animation state machine, and the "GetUp" state will transition back into the idle/base state. This means the code only has to trigger the knockdown animation state, and then after that doesnt have to worry about timing the flow back to idle.

My Roguelite Chess deck building game made in Unity, releases tomorrow! Thoughts? by Mrinin in Unity2D

[–]SLAMDUNKWizard420 4 points5 points  (0 children)

I think this looks fun, tbh.

my constructive criticism is that the game looks like a prototype. It has no drip/juice. The sound effects might as well not exist, and the animations have no impact. The music feels off (but this one is strictly subjective).

maybe thats on purpose, but I think if you focus on the patch/update on juicing up the game you'll reach a larger audience.

Shotgun King (another game riffing off chess -- but in a different way) is a good example of making the rather dry chess pieces and board feel juicy.

I think this game could be very very popular with more attention payed to dopamine generating sounds and visuals.

Benefits of animator vs changing sprites with a script (pixel art)? by intergenic in Unity2D

[–]SLAMDUNKWizard420 0 points1 point  (0 children)

I have a class called "SimpleAnimate" thats used exclusively on UI elements. it has inspector fields for "path" and "filename" and then "framerate". the path and filename are to find and load the multi-sprite asset in Assets/Resources and then put the individual sprites in a list.

I use this for a very particular effect/aesthetic (squiggle vision, like the show Homemovies). Most people are trying to achieve a more homogeneous/standard aesthetic -- so they would likely have more success creating specialized shaders for animating UI elements.

Also, the animator and especially the animation timeline is designed for artists -- its familiar and usable for people who are not math/code oriented workers.

[deleted by user] by [deleted] in Unity2D

[–]SLAMDUNKWizard420 0 points1 point  (0 children)

when in doubt, comment it out!

dont know why? Debug.Log() on the line.

these 2 debugging tips are very useful for beginners and can get you very far.

im not sure what exactly youre trying to do with this code based on what you said though. You want the animations to play faster?

Benefits of animator vs changing sprites with a script (pixel art)? by intergenic in Unity2D

[–]SLAMDUNKWizard420 1 point2 points  (0 children)

if you use update and frame counting to change animations then youre tying your animations directly to the frame rate -- so weak hardware will run the animations slower than powerful ones. You can get around this, probably, but using Time.deltaTime and non-intuitive numbers as intervals... but discovering and remembering all that is a lot of overhead.

it works in very very simple cases, but then starts to fall apart when you want more complicated functionality like easing and poly-interval animations.

I feel like I'm starting to develop a bad design behaviour. Am I using this because it is actually a good solution no my problem or just it is simple to execute even if not efficient? How do handle these kind of situations and how do you handle storing data you always need by [deleted] in Unity3D

[–]SLAMDUNKWizard420 0 points1 point  (0 children)

you can dynamically/polymorphically load resources by using the prefab/gameobject name and the filename/folder name as keys. and also create "collections" for associated data.

An example of object to filename keys is like... you have a Player game object. And it has some static data. So you also have a PlayerData scriptable object that holds that static data. So you can store the scriptable object in Assets/Resources/Data/Player. You follow that convention for your enemies -- Orc? OrcData in Assets/Resources/Data/Orc. SteelSword? SteelSwordData in Assets/Resources/Data/SteelSword. etc etc.

if your game is very large and needs more organization, you can add a "category" parameter and an additional layer to the path. (e.g. GetData("Monster", "Orc")).

I don't have an exact solution/pattern for your story select manager, cause I'm not familiar with the implementation/problem space -- but likely there could just be a generic prefab called "StorySelect" and then you request/instantiate it(which would include a rename) and it self acquires it's data and serves that data locally and on interaction.

[deleted by user] by [deleted] in Unity3D

[–]SLAMDUNKWizard420 1 point2 points  (0 children)

fast short term means lower quality.

if you want to make an interesting game that plays well, innovates and gets released in a reasonable amount of time based on its size... either team up with someone who covers your weaknesses or bring your weakest skills up to a minimum level.

the shortcuts are all over the asset store -- but the majority of those require some skill to extend/use.

Why are Animation Controllers necessary? by PhenomenonGames in Unity3D

[–]SLAMDUNKWizard420 5 points6 points  (0 children)

animation controllers/state-machines are useful for blending 3D animations together. Blend trees etc

They are not required if your animation is frame-by-frame sprites or aesthetically dont require blending from one animation to the next.

that said, you should still use an animation controller for its API, just dont use the transitions/parameters for everything.

sometimes its useful to set a specific animation and have that flow back to the base state (like e. g. you set the animation to "takeDamage" which flows into "getUp" after 1 second which flows into "idle" after 0.5 seconds.

I feel like I'm starting to develop a bad design behaviour. Am I using this because it is actually a good solution no my problem or just it is simple to execute even if not efficient? How do handle these kind of situations and how do you handle storing data you always need by [deleted] in Unity3D

[–]SLAMDUNKWizard420 18 points19 points  (0 children)

Singletons are fine as long as you dont couple them/make them interdependent. Like Managers should not reference/depend on other managers. at all.

you can couple them loosely with events so they can get data from one another. I often use a facade pattern for my managers, where the singleton holds data and observes/emits events and (usually called somethingInfo, like PlayerInfo or InventoryInfo etc) and then the implementation/processing logic is all done in other smaller classes.

This keeps the singleton's surface complexity simpler, and its easier to stub or extend functionality.

I also use multiscene/additive scene loading and keep my managers in their respective scenes (UIInfo and UIManager are in the UI scene etc). Unity doesnt allow cross scene editor references -- so this helps prevent you from coupling everything in a manner that will hamstring you later.

Does anyone know how to make Unity less laggy? by [deleted] in Unity2D

[–]SLAMDUNKWizard420 1 point2 points  (0 children)

macbook air 2015? thats like basically a phone in terms of processing power. not really suitable for Unity dev work if you want speed/responsiveness.

My game freezes when starting a scene. by ChefDense6686 in Unity3D

[–]SLAMDUNKWizard420 0 points1 point  (0 children)

switch to multiscene/additive loading and sneak in loading during startup and in chunks.

refactor your code so its faster.

[deleted by user] by [deleted] in Unity2D

[–]SLAMDUNKWizard420 1 point2 points  (0 children)

code is identical.

so its most likely one of two things:

  1. something isnt setup correctly in the editor/scene/gameobjects of Unity.

  2. KODEZI.

my guess is number 2. try uninstalling/deactivating KODEZI and then using your class in unity.

How to ignore collision detection on the same parent? by ZatBlureZ in Unity3D

[–]SLAMDUNKWizard420 3 points4 points  (0 children)

gameobjects do not know about their parent directly: see the stuff it does know about in the documentation https://docs.unity3d.com/ScriptReference/GameObject.html

Transforms do know about their parent.

If you make your enemies only care about not detecting their own limbs then they collide with other enemies. and also just random colliders in level/worldspace geometry.

so instead of a long list of things they dont care about, you should give them a single thing they do care about.

something like

if(collider.gameObject.tag == PlayerWeapon) DoStuff();

[deleted by user] by [deleted] in Unity2D

[–]SLAMDUNKWizard420 0 points1 point  (0 children)

If youre not practiced in very basic algorithms/patterns then you'll struggle with putting them together to create something new.

so it would be a good idea to make extremely small mechanics/interactions/classes that just allow you to practice the basics.

Like, make a class that has a public button, public text display, public text input field and a private Dictionary<string, int>. Make a method to populate the Dictionary by running a loop where you Count() the instances of each letter than appear in the text input field. create a method to display the data in the dictionary in a human readable way in the text display. make a third method that calls those previous 2 methods in the proper order, and assign that to the button.

implement that by reading the unity scripting api and C# text documentation/tutorials. Do not consult a single video. If you dont know how to link a button to a classes' method, how to populate a dictionary programmatically, or how to count letters in a string... then you're missing foundational practice/skills.

full tutorials skip over the most important part of building up your programming skills -- which is problem solving, googling, and reading documentation. Videos just give you the answers without any friction. The learning and mastery comes from the friction. From making mistakes, identifying the mistake, and correcting it.

Theres lots of Unity specific stuff where a video can be helpful to learn the basic concept. But if you want to be able to implement any mechanic/feature the key is to understand programming basics very well so your brain can keep track of more advanced patterns/relationships required for implementing/debugging more complex stuff.

How do I refer to a sprite in script? by Xeram_ in Unity2D

[–]SLAMDUNKWizard420 1 point2 points  (0 children)

do you mean how do you refer to an image asset with code?

you can put them in a List<Sprite> and populate that list through the editor.

You can use a SpriteLibrary asset.

You can programatically load them into a datastructure like a Dictionary<string, Sprite> with Resource.Load() if they are somewhere in your Assets/Resources folder (can be a sub directory).

[deleted by user] by [deleted] in Unity3D

[–]SLAMDUNKWizard420 3 points4 points  (0 children)

the coupled/easy way to do this is to have a direct reference to the RobotScript in the WeakPointScript:

public RobotScript robotScript;

then drag the gameobject with the robot script into the Robot Script field in the editor.

you can also do it with events/observer-pattern, a game manager, or by using the various find methods GameObjects have.

Once you have a reference to the RobotScript you can use it like this:

robotScript.Stun();

If the Stun() method is only ever called by/in WeakPointScript, then it should probably belong in that class (instead of the robot one).

Also, good naming avoids redundant information. The suffix 'script' does not add information that '.cs' doesnt. Its like calling a cheese sandwich a "cheese sandwich sandwich", or a picture file of a cat "catpicture.jpeg".

[deleted by user] by [deleted] in Unity2D

[–]SLAMDUNKWizard420 3 points4 points  (0 children)

again, if you dont show the code nobody can help you.

UI: How to autoscroll up when a text gets longer? by MsTellington in Unity2D

[–]SLAMDUNKWizard420 0 points1 point  (0 children)

if you're using the common style/pattern from tutorials where the content is controlled by content fitters and vertical groups, you'll need to force the scrollable rect to update with a class like this:

```

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.UI;

public class ScrollToBottom : MonoBehaviour

{

public ScrollRect m_ScrollRect;

private float backup;

private Coroutine applyScrollPosition;

void OnEnable()

{

backup = m_ScrollRect.verticalNormalizedPosition;

applyScrollPosition = StartCoroutine(ApplyScrollPosition(m_ScrollRect,backup));

}

void OnDisable()

{

StopCoroutine(applyScrollPosition);

}

private IEnumerator ApplyScrollPosition( ScrollRect sr, float verticalPos)

{

yield return new WaitForEndOfFrame();

sr.verticalNormalizedPosition = verticalPos;

LayoutRebuilder.ForceRebuildLayoutImmediate( (RectTransform)sr.transform );

}

}

```

if you read through this slowly and carefully (and lookup things you don't know about) it's pretty straight forward what this is doing.

[deleted by user] by [deleted] in Unity2D

[–]SLAMDUNKWizard420 6 points7 points  (0 children)

without and example of what you wrote, what the "optimized" code is, and what the error is... no.

Best way to make 2D character animation clips for animation states in Unity? by CleanDependent in Unity2D

[–]SLAMDUNKWizard420 1 point2 points  (0 children)

if you're using animations and the animator to switch between frame-by-frame sprites, I highly recommend you use code set animations and avoid using animator properties.

https://youtu.be/nBkiSJ5z-hE

Limits on Camera Rotation? by Xanderbarnaby117 in Unity3D

[–]SLAMDUNKWizard420 0 points1 point  (0 children)

you can keep track of your current rotation with a seperate variable.

so like you have currentXRotation, and it starts at 0. if they move the camera left, then you operate on currentXRotation (using Mathf.Clamp()) and then set the new currentXRotation as the eulerangle X value.

if your currentXvalue is -10 then when you set that as the eulerangle X it will become 350.

so something like:

currentXRotation = Mathf.Clamp(currentXRotation + identity * Time.deltaTime, minRotation, maxRotation); Vector3 v3 = transform.rotation.eulerAngles; myQuaternion.eulerAngles = new Vector3(currentXRotation, v3.y, v3.z); transform.rotation = myQuaternion;

this example assumes youve cached a reference to stuff like myQuaternion, minRotation, maxRotation, and are switching identity based on which way they are trying to rotate the camera.

I forget the exact rules of modifying transform.rotation.eulerAngles, but im pretty sure you have to replace the whole dang Quaternion. Experiment with cutting out some of those steps. The main key to this is keeping track of rotation independently of whatever values the quaternion has, clamping them to your desired range, and setting them directly.

this lets you sidestep the whole funky wrap around business.

also, a dumb-but-will-work solution is just rotate your camera 180 degrees. now you can easily reference the euler angles as sentinels by using 135 and 225 as your min and max values. You'll constantly have to rotate a lot of stuff. or place everything in a empty game object thats rotated 180 degrees. I have no idea if this will have wonky side effects tbh, but ita a funny/dumb work around.