#archived-code-general
1 messages ยท Page 164 of 1
This is your first error that Steam is not correctly configured, and you should have that file somewhere in that folder it seems. Assuming your stack overflow comes from the Steam problem I would start fixing that.
it doesnt
thats just the first error, the oom happens after some native allocators do stuff
i get the same steam thing on mono
i just need to get rid of that dumb allocator bug
did you update packages?
what would change from mono to il2cpp though
the way code compiles
Stripping levels are sometimes a problem, but I never seen an error like this from stripping.
they design native collections/allocators, it works for mono, fails in il2cpp because of bugs, they fix it in package, breaks again later because of unity version il2cpp compiler changes, they update packages and fix bug in il2cpp, repeat
Anyhow, a few idea's, but make a backup first:
update the packages
make a new empty scene and build only that
Make a new empty project and build only that
That way you could see if its a package problem, a problem in your scene, or a problem in your Unity.
Maybe even make a development build, auto attach the debugger and hope you see where it gets the stack overflow from, not sure if that will work.
if I have public int i and make it adjustable, and use the script on two different objects, can they both have different values for i or will they be the same?
Sure
alright thanks ๐
you slowed the leak
<@&502884371011731486>
!ban 845796106092412929 porn
dever_#0 was banned.
thnx, sorry for the ping
Probably better asked in #โฐ๏ธโterrain-3d, it has not much to do with coding.
In this specific case ensuring com.unity.entities is updated to version 1.0.11 and restarting the editor fixed it.
Hi,
I would like to make a transformation between two coordinate system. I have the coordinate of the green dot in left square and all points with red triangles. I heard about homogeneous transformation, but how do you do that in Unity ?
how do I get a variable from a script on a gameobject which is "collider" in void OnTriggerEnter2D(Collider2D, collider)
collider.gameObject.GetComponent<>()
I suppose ?
alright I'll try, thanks
How I'd do it is create a gameobject with the desired rotation and offset of the new coordinate system, and then use newCoordTransform.InverseTransformPoint(greenDotWorldPosition);
Wait no
That should be newCoordTransform.TransformPoint(greenDotLocalPositionOnNormalCoords)
And that should give you the world position that you're looking for
This assumes both white square/coordinate objects are the same in scale. If they differ in scale, idk. Probably some matrix math, way over my head.
I do a remap for that
Then it should work, let me know if it does. Just remember to take the local coords relative to the left square and plug them into TransformPoint on the transform on the right square.
What would be the best way to interact with objects with an animation? I've been thinking of some ways and one that might work is by having the interact animation on the player with the object, when the player is a child object of that object to interact with. In this case I'm trying to do this with a door that will trigger an animation on the player to open it. I need to use this while additively loading another scene since my game is in a style that blends between them.
why would player be child of the door?
Hi all, i have a basic player set up with a rocket launcher, which is a prefab. The rocket is also a prefab, and is setup as a child of the launcher. Everything seems fine until I enter play mode and look around with the player, at which point the rotation for the child prefab bugs out. For horizontal looking around the entire player is rotated, while for up / down only the "tiltobject" object is rotated. The scale for all of the prefabs is 1.
And what is the problem with that ? I think the player rotations on X and Z are locked to prevent him from falling
I mean set the player as a child object when you interact with it then play the animation used to open it
Not always being a child object of the door just when the animation is played
yeah but why
Why? Because I need to make the animation lol so wouldn't it be easier to set it as a child before playing that animation
hmm, I'm thinking that you would have the door have coords, getcomponent of those and implement it into the animation.
I am a noob though, probably a better way to do it
I was only thinking of it like this because I'm using it to change levels
It's only a 1 way
I could do it another way, but I dunno if it's doable to create a AABB with a custom shape (the left one is an AABB that contains object following axis and the right one is the result I would need)
look at the second image, the rotation of the rocket changes for some reason despite only a parent way up in the higherarchy changing
The second image is when tilt is rotated right ?
if any of the parent objects get rotated, that child object also rotates but not by the same amount, for some reason the rotation of the child is being altered when it shouldnt
also seems to happen for position, example:
Ok, i tried it again and it only seems to be that particular prefab that does it, probably a code issue idk
ok, it was a rigidbody with iskinematic set to true that caused this
ok, so new question
How can I keep a child object, that has a rigidbody on it (iskinematic = true) in the same position relative to the parent when the parent moves?
(parent doesn't have an rb)
found solution, I just had to do nvm this didnt work lol
my player gets stuck when dashing into walls (Warning: messy code because im a beginner)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Dash_ : MonoBehaviour
{
// Dasht gerade?
public bool dasht_gereade;
public float ZeitSeitLetztemDash;
public float DashReloadZeit;
// Wie Weit ist der dash?
public float Dash_weite;
private void PerformDash()
{
dasht_gereade = true;
float dashDirection = sr.flipX ? -1f : 1f;
rb.velocity = new Vector2(dashDirection * Dash_weite, rb.velocity.y);
ZeitSeitLetztemDash = 0f;
Invoke("StopDashing", 0.2f);
}
private void StopDashing()
{
dasht_gereade = false;
}
}
Do you have a video or similar to show exactly how it gets stuck?
i send one
ok here is it
private void PerformDash()
{
dasht_gereade = true;
float dashDirection = sr.flipX ? -1f : 1f;
rb.velocity = new Vector2(dashDirection * Dash_weite, rb.velocity.y);
ZeitSeitLetztemDash = 0f;
Invoke("StopDashing", 0.3f);
}
private void StopDashing()
{
dasht_gereade = false;
}
Instead of setting the velocity, try adding force instead and see if it helps at all
Why Unity Engine Treats warnnings as Errors
It doesn't, warnings are warnings and errors are errors.
warnings are yellow, errors are red
I. kinda think this must be a bug recently introduced
You have a crap ton of warnings in your scripts, probably at the bottom of that stack trace is an error.
hide inherit component should be warning
weird
I would have expected this to be all different warnings instead.
Yes
Yeah, I would have expected ~12 different warnings + your error.
and I also edited that damn code 10 hours ago
there is an error CS8805 in the middle
and I played that 20 mins ago
that is a real error
not sure why it's combined with warnings
but the error and warning are grouped to one message, maybe editor bugs
just post the code on line 13 or whatever so we can see if its actually the issue or not
i cant see stacktace of that cs8805
it is just warning i swear
How to do this?
I want to prevent gameobject from disabling
you can't
just don[t disable it in the first place
cant help if you dont post code :)
that's just a warning
yes
but the top level statements thing is elsewhere
alright thanks
I dont know where it is
it's unfortunately not showing a filename/line number
name is a reserved keyword afaik
the CS8805 error even does not specific which line and file
check any recently edited files
and so is camera
they're not reserved or keyweords
they are used by Component though
so this will hide them
hence the warning
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
{
}
public class PhaseHandler : MonoBehaviour
{
struct Dialog
{
bool isAllyDialog;
string name;
string description;
float removetime;
public Dialog(bool isAllyDialog, string name, string description, float removetime)
{
this.isAllyDialog = isAllyDialog;
this.name = name;
this.description = description;
this.removetime = removetime;
}
void DisplayDialogs()
{
}
}
public List<int> phasePoint;
public GameObject MissionDescription;
public GameObject MissionIndicator; // ๋ฏธ์
์ง์ฒ๋ ํ์ํ ๊ณณ
[Header("Do not edit")]
public int currentPhase = 0;
public int currentPhaseIndicator = 0;
Dialog dialog1 = new Dialog(true, "Commands HQ", "์๋
ํ์ธ์, ๋น์ ์ด ๋ฏธ์
2์์ ๋ณด๋ 1๋ฒ์งธ ๋์ฌ์
๋๋ค.", 2f);
Dialog dialog2 = new Dialog(true, "Commands HQ", "์๋
ํ์ธ์, ๋น์ ์ด ๋ฏธ์
2์์ ๋ณด๋ 2๋ฒ์งธ ๋์ฌ์
๋๋ค.", 2f);
Dialog dialog3 = new Dialog(true, "Commands HQ", "์๋
ํ์ธ์, ๋น์ ์ด ๋ฏธ์
2์์ ๋ณด๋ 3๋ฒ์งธ ๋์ฌ์
๋๋ค.", 2f);
Dialog dialog4 = new Dialog(true, "Commands HQ", "์๋
ํ์ธ์, ๋น์ ์ด ๋ฏธ์
2์์ ๋ณด๋ 4๋ฒ์งธ ๋์ฌ์
๋๋ค.", 2f);
Dialog dialog5 = new Dialog(true, "Commands HQ", "์๋
ํ์ธ์, ๋น์ ์ด ๋ฏธ์
2์์ ๋ณด๋ 5๋ฒ์งธ ๋์ฌ์
๋๋ค.", 2f);
// ํ์ด์ฆ ๊ฐ์๋ ๋ฐฐ์ด์ ๊ธธ์ด =.Count
// ํ์ด์ฆ ํด๋ฆฌ์ด๊น์ง ํ์ํ ์ง์ฒ๋๋ ๋ฐฐ์ด ์ ๊ฐ
// Start is called before the first frame update
void Start()
{
currentPhase = 0;
currentPhaseIndicator = phasePoint[currentPhase];
}
// Update is called once per frame
void FixedUpdate()
{
if(phasePoint[currentPhase] == 0)
{
currentPhase++;
//next Phase
}
UpdateIndicator();
}
void UpdateIndicator()
{
MissionIndicator.GetComponent<TMP_Text>().text = currentPhaseIndicator.ToString() + " / " + phasePoint[currentPhase].ToString();
}
}
using TMPro;
{
}```
this is what i edited recently
shit
lmao
that's probably confusing everything
is it fixed?
Hello. Is anyone aware of any .Net libraries to embed Unity into a .Net web application (specifically Blazor WASM). I would like to embed the game and allow for the following: ```
- Allow events from the website to be sent to the game, like pushing a button on the website (as well as keyboard/mouse events)
- Allow for the application to pull models/textures from an external repository (a file server) and include them into a scene. The models dont have to be introduced to the scene while it is running, it can be loaded first before the scene starts.```
idk about embedding it into Blazor WASM but you can certainly use javascript as an intermediary between the Blazor WASM and the Unity WASM
assuming Blazor has ways to interact with JS
Yeah it does. Yeah, I figure I could just copy the files over like any other website, just wasn't sure if there were any NuGet packages that would be helpful
Unity has pretty good runtime texture importing stuff built in but you will probably need a plugin for 3D model files
perhaps multiple - depending on which formats you want to support
Any tips on best practices for localization? Any negatives to using com.unity.localization?
had some issues when also using odin inspector, but unity localization has been solid in the projects i've used it
K. I'm not using OI (yet - the pull has been strong though lol) so I'm ok there. Any issues with TMPro? The docs seem to use UI.Text examples
I haven't gotten far in the docs yet, just skimming
tmp pro has worked without a hitch with localization ๐ the only thing is to find a good context-aware naming for your keys (imo atleast), and be very well aware that "Accept" could be "brzkneckschwitz" in some language you aren't aware of when adding it ๐
heh
What do you mean by "context aware" naming? I hadn't put much thought into my key naming convention/scheme yet
dont cross post
if your key is for a word or sentence that has multiple meanings i guess.
key: "CompletedText" might mean it's just the translation for "Completed" or it could be the message when completing a level "Congrats on completing level 4, enjoy level 5!"
so name keys smart is what i mean ๐ so you don't have to think about what key goes to what text
Yeah, I would probably name keys overly specific like TITLESCREEN_STEP1_TITLE
or something :p
sounds good ๐
Do you have an actual question? You can get help if you just ask it instead of asking for credentials or whatever is going on
@regal flame Dumb question maybe, but how do I tie the TMPro component to the key?
I don't see any "key" field in the tmpro component
rightclick the text component and Localize
Yeah, I got it now.. that was the little nugget of knowledge I was missing ("localize" buried under the right click menu)
I'm not sure I love this string table UI editor.. have you done this before at scale? How in the world am I going to get translations into the game easily? I'm currently envisioning something like a google doc spreadsheet with key/translation, I could outsource translation of the strings, but then what.. copy and paste those 1 by 1 into the string table in unity..?
yeah there is some support for that, haven't tried it through some spreadsheet doc or with a translation service though
should be doable - i made a script at some point to bulk-add audio files to the asset table, so you can do plenty that way if you need to
they support a few formats for easy adding iirc. don't remember where i saw that but i think i saw CSV atleast
https://docs.unity3d.com/Packages/com.unity.localization@0.9/manual/CSV.html yeah they support plenty, as long as it works with the translation service
hey everyone, ive been using some scripts that have interactable events attached on them and im trying to trigger these events by code. i tried getting the interactable component and say call the onSelectEntered event but i get an error saying non invocable member. is there a solution for this? thanks!
Hey I have a mathematical question, just not sure how to solve it.
is it code-related?
Yep
Sec
So given a units position in 3d space, it is headed in a direction at a fixed speed
Hey! I managed to get that thing we discussed yesterday implemented. I added the script to each of the prefabs but I'm lost where to go next? Thanks
Now I have another unit who moves at a fixed speed, and I need to create the direction vector where he would perfectly intersect with the first unit.
These two units can be anywhere in 3D space, I need to figure out the direction vector of Unit 2 so that it will meet Unit 1 after it's moving a given speed in any given direction
Discord didn't do the reply to the message I linked #archived-code-general message
crossposting is against the rules as well #๐โcode-of-conduct
I'm sure there's a mathematical equation to solve this tbh
your first unit can be represented as Pos1+tDir1
then you want to find the Dir2 in Pos2+tDir2 such that Pos1+tDir1=Pos2+tDir2
bold font means vector
Yes exactly
Holy lag
They should be equal
Wait... I can't just subtract pos2 on the left and get the result can I?
are they both moving at the same speed?
No
the most difiicult part is |Dir2|=speed given and you have to solve for
X1+tVx1=X2+tVx2
Y1+tVy1=Y2+tVy2
Z1+tVz1=Z2+tVz2 and
|(Vx2,Vy2,Vz2)| =speed
Awesome, thanks. On one hand, this might just be a future-me problem.. but I have one project that's got embedded english and localizing it would be a nightmare (the project is some 150k lines of code already). We're starting a new project so I wanted to make sure I had the localization thing taken care of at the outset.
Like one unit could be moving at 500units/s while the other unit could be 2000/s
To give you an idea, it's for AI projectiles predicting where to shoot towards players
if this is the case you might have a situation where there isn't actually a solution
well, a real solution, with t > 0
wait for some expert in linear algebra solve this system of non-linear equations...
This can be done on just the x and z axis but honestly the approach will still be the same
Hey, sorry. Following up from where I left this. I added a "Building" or now called "PrefabManager" to each of the building component prefabs. I'm not sure how to import them now though?
typically yeah but you do have a subset of situations where there is no solution
So I have a class for Prefab manager, and I now need to get the data from that class into the inspector?
But we dont know the constraints of your system so maybe those subsets never actually come up
at least Pos1 and Dir1 and Pos2 are known, may not be much difficult
I'm not sure how there wouldn't be
There should always be a solution
imagine an object at position 0,0,1, moving with velocity 0,0,10
now imagine the object you want to intercept it is at 0,0,0, and can only move with speed 1
Oh
if you follow the equations you will get a solution, but it will be with t negative
not a "real" solution
the most trivial case
find x such that x+1=2 and x+1=3, it has no solution
If the movement speed of the unit is faster than the projectile
Or even easier.... if person2 had a velocity of zero :p
there may not be solution of a system of equations
I see what you mean now
If the projectile has a speed of 50, and the player has a speed of 400 and is moving away from the projectile
It will never hit
Hello! Reaching out to see if I am confused on the use of Texture2D.Reinitialize... I want to use it to resize a texture but everytime I do, it results in a grey or corrupted image. For example, I would do something like this:
QR = DownloadHandlerTexture.GetContent(requestTexture);
QR.Reinitialize(128, 128);
QR.Apply();
Hmm I wonder how complicated this is then
Am I missing a step in this process that removes the image data? I tried Texture2D.Resize but it says its deprecated and I should use Reinitialize.
Seems like the documentation is confusing because another person here is having the same issue. I just want to resize an image ๐ญ
Do you want to resize an image in a canvas in the UI?
No. I am receiving an image from an API and I am resizing it to paste it on a model.
It comes in at 1000x1000 but it needs to be 128x128
Its okay! I know there is a way to do it, its just finding out how.
Pasting it on the model works find, its just too big.
oof yeah that can be rough to fix if localization wasn't a feature you had initially planned on
Localization is one of those things that are like "worry about it later when you're selling a million copies" but also, if you do that you have a monster headache of work.. All the embedded strings in that project are enough work for me to just say "sorry, it's gonna be english only"
the funny thing is my project is super popular in brazil for some reason, even though it's not available in the store there
So portuguese would be an obvious first locale
(I suspect that a lot of people there VPN through USA and set their stores to USA for some reason - my game checks country based on self-reported IP, and often these players "sign up" in USA but then sign in later from .br)
yeah unfortunately it's hard to tell early on if it's even worth worrying about ๐
if you're making a text or audio heavy game i'd say its worth worrying about early, otherwise its not too big of a hiccup to add later
Drag and drop
Just the entire prefab?
Not the specific script component I added to each?
Like this.. And I have written hundreds of "renderers" that just render text inline like that.. I ragret nothing! ...although it means english only ๐
there is no difference between the specific script and the entire prefab
public Building[] buildings;```
ouf similar to my project, luckily not too many strings like that! that's a pain ๐
Unity is smart and will detect you have the script attached and will grab it, its a nice little time saver
ahhh ty!
Hmm, why this doesn't work. It shows error object was destroyed. Controller.Func(prefab); Destroy(gameobject):
Controller script... Func(gameobject prefab); Currentprefab = prefab;
It shows error object was destroyed
Show the full actual error message
And share your code as per !code
๐ Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
If anyone is confused like I am, this does the job!
{
// Create a new Texture2D with the desired resolution
Texture2D resizedTexture = new Texture2D(targetWidth, targetHeight, sourceTexture.format, false);
// Calculate the step size in x and y directions
float xStep = 1.0f / (float)targetWidth;
float yStep = 1.0f / (float)targetHeight;
// Loop through the target resolution pixels
for (int y = 0; y < targetHeight; y++)
{
for (int x = 0; x < targetWidth; x++)
{
// Calculate the normalized texture coordinate for the original texture
float u = xStep * x;
float v = yStep * y;
// Sample the original texture using the normalized coordinate
Color color = sourceTexture.GetPixelBilinear(u, v);
// Set the pixel color in the resized texture
resizedTexture.SetPixel(x, y, color);
}
}
// Apply changes to the resized texture
resizedTexture.Apply();
return resizedTexture;
}
}```
That prefab is destroyed too, how to avoid it. When I commented //Destroy(gameobject) then it works
I have no idea what you are talking about
you need to give some context as to what is going on here
and what you want to happen
Destroy destroys whatever object you pass into it
nothing more
nothing less
Simply, I have perk object(cube), and when player equip it then player should store that cube inside controller so when another perk is equipped then drop current one
then player should store that cube inside controller
What does this mean
StoredPerk = prefab;
It sounds like you are destroying the prefab ref, and not a copy of the prefab you made
Are you calling Instantiate in your code?
I'm back, I am going to try and mess around and look online to see if I can solve this issue
hello, everyone. I am looking for a team with unpaid collaboration. Plz DM me.
!collab
We do not accept job or collab posts on discord.
Please use the forums:
โข Commercial Job Seeking
โข Commercial Job Offering
โข Non Commercial Collaboration
Wow that was fast
Yep
https://www.youtube.com/watch?v=aVwxzDHniEw here is the video im using
Bรฉzier curves - how do they do?
They're used for animation, text rendering, and all sorts of curved shapes! But how do they actually work? well, like, that's what the video is about, so, watch it to find out etc!!
โข Lots of love to
๐ Jazz "queenjazz" Mickle for making the music โฑ https://queenjazz.bandcamp.com/
๐ Grant "3Blue1Brown" Sanderson...
@fluid willow
public Vector3 QuadraticBezier(Vector3 a, Vector3 b, Vector3 c, float t)
{
Vector3 d = Vector3.Lerp(a, c, t);
Vector3 e = Vector3.Lerp(c, b, t);
Vector3 f = Vector3.Lerp(d, e, t);
return f;
}
Thank you very much, you have been around for a very long time in this discord - every time I pop in you are always extremely helpful. It means a lot โค๏ธ
Codemonkey has a tutorial explaining it, you might want to take a look at the tut
btw how do you think i should draw the curves on a texture, i could use a 2d marching cubes algorithm but im not sure yet
you could use the line renderer
im thinking just use the marching cubes and then generate the texture based on the intersection point
to speed it up i could also only place the cubes next to the curve so it does not have to check the entire texture
I'd like to be very certain, I really can't make interfaces have a fixed method, can I?
I can write a method in a interface like public void act(){} but it can't actually be found by classes that implements it.
I am aware that one could use extension methods to get that effect, but it has some issues:
- minor issue: The class implementing it needs to have
this.to be able to use the method. - major issue: Animation events can't locate it, making it inviable for my case.
default interface methods require casting to the interface to use the method
Ow... Is that recommended though? Even though the other way require me to write the same method in every implementation '^^
Probably can be slightly optimized by caching its interface after casting
casting to the interface shouldn't really incur any costs unless it is a value type since that would box it. but you have to operate on the instance as the interface if you want to use a default interface method. the alternative is to not use a default interface method and just implement the method on the object normally
Alright, I would prefer avoiding to copy-paste the exact same code to anything that implements it, so I'll go with casting.
Probably need to search up what casting is since I don't understand some stuff, anyway, thanks
https://youtu.be/XtQMytORBmM?t=2648 yo does anyone know how to animate like how he just did ๐ (timestamp in the link)
GMTK is powered by Patreon - https://www.patreon.com/GameMakersToolkit
Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and then give you some goals to learn ...
i want to make the flap animation but idk how he did it like that in unity
all i have to animate with is a png with the wing going up, down and the bird's body
Not a code question
You need an image with all your animation states in it. Then import it and slice it. Then put that into your animation, and run the animation in a loop.
Further questions go in #๐โanimation
right sorry
thanks a lot
You can use both a BaseClass and an Interface for this
A class can both inherit from another class and implement interfaces at the same time
How can I create a UI that would only disappear if the user puts in a specific word/phrase?
Probably from an array
so if you need to have some specific method that is the same on all implementations on your interfaces, you can just do:
public interface IMyThing {
void SomeMethod();
void SomeOtherMethod
}
public abstract class MyThingBase : IMyThing {
public void SomeMethod() { ... }
public abstract void SomeOtherMethod();
}
public class MyThingA : MyThingBase {
public override void SomeOtherMethod() { ... }
}
@pastel patio
@swift falcon you can disable the gameObject the Ui is sittong on or just disable the componenet that is being renderer.
Oh wait!
I am so dumb
Haha thatโs what no sleep does to you
Thank you @robust dome
gameObject.SetActive(false) / GetComponenet<Image>().enabled = false
just a small example ;D
Thank you :)
Can a monobehaviour have a static variable pointing to a scriptable object? (I'd like to make a system of collectables or unlockables that can be tracked across several scenes and saved/loaded to player prefs. But I'd like to do it with minimal code / setup changes. Ideally I'd like to drag a prefab onto a scene and have it "registered" - not sure how to accomplish the opposite - to remove a collectible from my project when it's removed in the editor. (because if I just use ondestroy then I'd loose my collectibles at runtime when I unload a scene, right?
Sure it can but you won't be dragging and dropping anything into a static field
because that's not how static fields work
I'd like to make a system of collectables or unlockables that can be tracked across several scenes and saved/loaded to player prefs.
Sounds like a DDOL singleton
Sorry for late reply, wasn't around.
Well, I know that I can do something alike, however right now the system somewhat looks like this:
Creature - Player [IItemWielder]
\
Npc - ExampleCreature
Villager [IItemWielder]
Here it becomes kinda apparent that only some creatures have IItemWielder, and making it a baseclass sounds... Uhm well...
Creature - WielderCreature - Player
\ \
\ Villager
ExampleCreature
Besides the new arrangement, it can also no longer share basic npc functions, so that's why I'd not make IItemWielder a baseClass
Oooooh no... And then remembered that I needed it to be accessible by animation events ๐คฆโโ๏ธ
Basically no matter extension methods or method in interface, they simply don't work.
The only way would then be either writing methods that do the link, or just pasting the method in every class, both end up kinda the same... Gosh I really am not a fan of interfaces, such a headache half the time
hi, do you know how in my 2D URP game i can add some kind of effect to the light, like to make the torch look like it actually gives light? because right now all I have is stationary lighting, and it should kind of wave
Uhh... Make an animation or write a script for it, I guess?
Slight flicker or shrink&expansion isn't very difficult to add
Animation is normally not really recommended, a bit heavier then it's necessary, but if you want to avoid writing code ig you could choose that.
Particle systems with some sparks should also make it a bit more lively
Thanks, I think chat gpt actually came through for me regarding removing collectibles from the scenes ([InitializeOnLoad] public class SceneHierarchyChangeListener { static SceneHierarchyChangeListener() { EditorApplication.hierarchyChanged += OnHierarchyChanged; } (haven't tested it yet but looks promising, hope that hook isn't "hallucinated" ๐
This will only work in the editor
yeah, that's what I want an automatic way to maintain a project wide list of collectibles. So they're automatically registered when someone adds them to a level in the game, and deregisters if they're removed.
I have a question about collision callbacks. A is the parent of B. if i have a rigidbody on a gameobject A, and a capsule collider on gameobject B, should OnCollisionStay be called on monobehaviours on A, B, or both?
I'd expect the object with the rigid body. A non trigger collider will look up the hierarchy for the closest parent with a rigidbody and contribute to it's collisions.
Yeah the collision message will get reported on the object that has the Rigidbody. As long as you got your script there, it will receive OnCollision* messages
yea i just wrote a script to test it and you guys are right
kinda annoying but i guess it makes sense thanks
yep, you can have multiple colliders but only one rigidbody so it does kind of make sense that the rigidbody collects all the collisions
It seems weird that a "project wide list of collectibles" would be related to the hierarchy
doesn't sound right at all
the hierarchy is to have something to hook when someone removes a collectible from a level, this info will be passed to the scriptable object asset maintaining the list.
oh when you say collectible you mean something like a coin?
yeah
should have been more explicit, I was thinking something like a korok in botw
Hey I wanted to make an ActionController for different enemies and I also have abilities like the following. Sometimes I need to run a function on another ability if it exists. Do you know a good way to handle it or is sending the ability as a parameter the only solution?
[System.Serializable]
public class ActionPunch : ActionAbility {
public void Init(State _state, Essentials _essentials, Surroundings _surroundings, ActionPunchData _data) {
state = _state;
essentials = _essentials;
surroundings = _surroundings;
data = _data;
}
public override void PerformAction(params object[] parameters) {
if (parameters.Length > 2
&& parameters[0] is bool wantPunch
&& parameters[1] is bool isDash
&& parameters[2] is Vector3 punchDirection
)
{
if (wantPunch){
if(CheckPunchRequirements(isDash))
{
if(isDash){
DashPunch(punchDirection);
}else{
RegularPunch(punchDirection);
}
}
}
}
}
private bool CheckPunchRequirements(bool dash) {
if(!state.AlwaysAllowedStateChange()){
return false;
}
if (groundTime != null && groundTime == null){
if (!groundTime.Grounded()){
return false;
}
}else{
if(!surroundings.foundGround){
return false;
}
}
if(groundTime != null)
{ groundTime.Update(); }
return true;
}
}
without knowing anything about your architecture it's not really possible to say
if you want to call a function on an object, you need a reference to that object
the best way to get that reference is highly dependent on your architecture
I don't have one yet
that's how it looks basically.
public class GhoulActionController {
Ability1;
Ability2;
UpdateAbilities()
wantAbility1 = true;
Run.Ability1()
}
Im having issues with unity saying basic functions like start are unused? this only started happening like 10 minutes ago and ive tried regenerating project files to no luck
That is not a screenshot of unity
So "Unity" is not saying that
Yea i know its vscode? How do i stop it from saying default functions are unused
VSCode has a terrible Unity integration. Would recommend switching to a better IDE
you'd have to suppress the warnings manually I guess
how can i do that? that seems like an alright solution
doesn't it give you suggestions for the warning?
theres two, the top one just removes the start function and the one below just adds private to the start of it
which funnily enough DOESN'T remove the problem
I currently have a grenade with these two scripts on it:
Grenade.cs https://hastebin.com/share/yeseculize.csharp, and
Explosion.cs https://hastebin.com/share/ziyukaxagu.csharp.
My enemy has multiple colliders on it, and so my grenade counts each of those colliders seperately, and as such deals damage to the enemy multiple times. Here's a screenshot of the enemy structure, for reference. How would I make it so that the grenade only applies damage for each enemy once, even when contacting multiple colliders on the same enemy?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
you'll have a better time just swapping to VS instead of jumping through hoops to use vscode
Yea i think ill just bite the bullet and swap, I don't want to go through the hassle just to hide a blue squiggly line and a bit of text
I deal with something similar, what I do is grab the root of the whole character and store that. Then when it hits multiple colliders, each one will find the same root and you can ignore the following collisions
is there a alternative way to get a sprite from sprite atlas without using getsprite()? the clone of the sprite causes errors
what kind of errors
"Could not extract GUID in text file" in the .unity file of the scene
basically im trying to assign a sprite from a sprite atlas to a player but anytime i use getsprite in onvalidate the errors pop up
like it does work, but the editor doesnt like it
Well yeah those are just in memory sprites
You won't be able to save them to the scene file
yeah trying to save is how i first got the errors, i wanna find some alternative so it can be shown in the editor since that doesnt work
Can you send me the code you used for that? I thought of doing that but couldnโt figure out how
is there some way to detect and change values before/after it gets saved to the file? im thinking of setting the sprite of whatever has been given a getsprite to null before saving and then reassigning it again when its done (unless you know of a better way to solve this, im just guessing at this point lol)
Steps:
- you are already getting the root at one point, so first make a list.
List<Transform> alreadyHit = new(); - Before you apply damage, make sure its not in the list. If it is, skip it
- If its not in the list, then apply damage and add it to the list
one thing which I havent seen on the internet about and dont really wanna bother asking GPT, is there a way to detect an animation that is currently playing?
im 100% aware you can check an animation state, like if the model is on Open or Close or whatever, but my model freezes on the last frame of the animation once its complete, which means it'll always detect it on that animation and its sort of a problem for me as im trying to code a deadbolt right now and want to make sure it cant be used while the door is moving to prevent softlocks
so itd be perfect if theres some way to see if theres any current animation playing not frozen and then have the deadbolt be inactive during that time, which i can work out myself but just need info on the former
This is my setup for creating a TMP object (everything must be done in scripting at runtime for an unrelated reason)```cs
private void setupTMP()
{
textObj = new GameObject("GrabberText");
textObj.transform.parent = GameObject.Find("Menu").transform;
textObj.AddComponent<CanvasRenderer>();
textVisuals = textObj.AddComponent<TextMeshProUGUI>();
textVisuals.color = Color.white;
textVisuals.fontSize = 50;
textVisuals.font = Resources.FindObjectsOfTypeAll<TMP_FontAsset>().Single(font => font.name == "Blogger_Sans-Bold SDF");
textVisuals.fontMaterial = Resources.FindObjectsOfTypeAll<Material>().Single(material => material.name == "Blogger_Sans-Bold SDF Instruction");
textVisuals.enableWordWrapping = false;
textVisuals.alignment = TextAlignmentOptions.BaselineLeft;
textObj.GetComponent<RectTransform>().anchorMin = Vector2.zero;
textObj.GetComponent<RectTransform>().anchorMax = Vector2.zero;
textObj.transform.localPosition = new Vector3(-854, -531, 0);
textObj.transform.localRotation = Quaternion.identity;
textObj.transform.localScale = Vector3.one;
textObj.layer = LayerMask.NameToLayer("UI");
}```The goal is to put some text in the lower left corner of the screen, regardless of resolution/aspect ration (hence anchorMin and anchorMax = 0). I'm setting the location of the text on the screen w/ the transform's local position (values found through trial and error to get it in the right part of the screen). Now, it works 90% of the time... (the text is Grabs: 0 in the pictures)
Now, all that's assuming I boot the game with the intended aspect ratio and then change the resolution... If instead I boot the game in a resolution like the one pictured here, the text loads off screen (in the black bars) and then changing the resolution just moves the text around out of the frame...
If I boot the game in a wide ratio, however, it doesn't appear in the corner. Again, changing the resolution moves the text appropriately, meaning it never reaches the corner.
Using only runtime scripting, how can I actually anchor the text to the corner of the screen?
I have imported dll's of a .NET lib into unity and i'm using it to launch a minecraft instance, everything is working well with offline auth,
but the real problem comes when i need to execute a function to connect to Microsoft account (for premiums), the function should (normaly) open a (integrated i gess) web-browser to login to microsoft account, but instead Unity is throwing me this error :
If anyone know something about making this default WebUI to work, i will be grateful ๐
skimming through, part of the error is probably related to how you had to manually find that local position to assign. Its quite a large negative value which indicates to me this isnt anchored to the bottom left at all
I dont know much about anchoring through runtime, but an easy solution really would just be do it manually (in inspector) in your own project and debug the values so you can see what you really need to set.
I don't know what these errors mean, so could someone help? Also, I'm following this tutorial: https://www.youtube.com/watch?v=e2RXDso6fWU
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PlayFab;
using PlayFab.ClientModels;
public class PlayfabManager : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Login();
}
void Login() {
var request = new LoginWithCustomIDRequest {
CustomId = SystemInfo.deviceUniqueIdentifier,
CreateAccount = true
};
PlayFabClientAPI.LoginWithCustomID(request, OnSuccess, OnError);
}
void OnSuccess(LoginResult result) {
Debug.Log("Successful Login/Account Create!");
}
void OnError(PlayFabError error) {
Debug.Log("Error while Logging in/Creating Account!");
Debug.Log(error.GenerateErrorReport());
}
public void SendLeaderboard(int score) {
var request = new UpdatePlayerStatisticsRequest {
Statistics = new list<StatisticUpdate> {
new StatisticUpdate {
StatisticName = "Arena",
Value = score
}
}
};
PlayFabClientAPI.UpdatePlayerStatistics(request, OnSuccess, OnLeaderboardUpdate, OnError);
}
void OnLeaderboardUpdate(UpdatePlayerStatisticsResult result) {
Debug.Log("Successful Leaderboard Sent!");
}
public void GetLeaderboard() {
var request = new GetLeaderboardRequest {
StatisticName = "Arena",
StartPosition = 0,
MaxResultsCount = 10,
};
PlayFabClientAPI.GetLeaderboard(request, OnLeaderboardGet, OnError);
}
void OnLeaderboardGet(GetLeaderboardResult result) {
foreach (var item in result.Leaderboard) {
Debug.Log(item.Position + " " + item.PlayFabId + " " + item.StatValue);
}
}
}
๐ Support me and DOWNLOAD Unity project: https://www.patreon.com/posts/46591972?s=yt
โด๏ธ NEXT PART: Design your leaderboard in UI: https://youtu.be/jlZYr9Hbmys
3๏ธโฃ Next Playfab part: https://youtu.be/9-vW2z88xCs
1๏ธโฃ First Playfab video: https://youtu.be/DQWYMfZyMNU
๐ Join our Discord (and get help โจ): https://discord.gg/hNnZRnqf4s
๐ต Follow me on...
i have a script i wanna use as a base, and i wanna have multiple other scripts that inherit from it, what is the best way to set that up ?
for instance all equipment has a script that should be apart of all types of equipment, but the specific types, do diffrent things
nvm i figured it out
There are a few ways to do that
Inheritance, composition, strategy pattern, decorator pattern...
Hello, I am looking for coders that could help with the I Love Katamari Reroll + Katamari Amore game. If youโre interested, please DM me. Thanks.
hello
could you please assist me
I need some help on ecpm man. I have a super low ecpm and wanna increase it.
!collab
We do not accept job or collab posts on discord.
Please use the forums:
โข Commercial Job Seeking
โข Commercial Job Offering
โข Non Commercial Collaboration
This is prolly more of a #๐ฒโui-ux question, this is the coding channel
I'm having trouble figuring out how to get the missile to flytowards the target dummy. They orbit around the target. I've also tried setting the angular velocity to zero but that didnt have much effect as well. I have provided my locomotion code these missiles use. What can I do to improve my attempt so these missiles fly directly towards any target and not orbit?
private void Update()
{
if (!target)
{
GetRandomTarget();
}
Vector3 direction = target.transform.position - transform.position;
direction = Vector3.Normalize(direction);
//Quaternion targetRotation = Quaternion.LookRotation(direction);
Vector3 targetRotation = Quaternion.LookRotation(direction).eulerAngles;
transform.LookAt(target.transform);
//transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 100);
}
private void FixedUpdate()
{
if (target)
{
Vector3 moveTowards = (target.transform.position - transform.position).normalized;
rb.AddForce(moveTowards * moveSpeed);
}
else
{
rb.AddForce(Vector3.forward * moveSpeed);
}
}
Orbiting occurs when the force moving it towards the target is too weak to pull it in and overwhelm the centripetal force of the object continuing to move forward
Your force that corrects the projectiles course towards the target needs to just be stronger to overcome its inertia
I really need help Ive been sitting here for a few hours and I cant get my head around this shit.
https://hatebin.com/rnuttrauot
So my first script here is linked to another script for a door (yes Ive done a door script like this because I wanted a small cutscene animation to play while opening it because I also need to additively load a scene)
https://hatebin.com/qqbyqsnauv
On THIS loadout script I need my weapons to be holstered automatically. It works perfectly fine with my keys 1,2,3. 3 is just an empty object for hands or whatever, 1 is a pistol and 2 is for a rifle. But for some reason if I call it from that first door script (need them to holster) then it is stuck in a loop of holstering and equipping constantly. The m4IsEquipped does turn false and the pistolIsEquipped does aswell and the selected weapon int also changes, but the weapon I just had out is stuck in that loop
after the animation is done for going through the door, it teleports me back to the original position for a split second aswell
will provide footage of what I mean 1 moment
I dont completely understand. When adding more force to rb.AddForce(moveTowards * moveSpeed); they fly a more direct path but at increased speed. I knew this would happen but tried it just to see. They eventually return to an orbit pattern as well. I'm not quite sure how to implement your suggestion.
Hey does anyone have a replacement for tags? My tags are about to become a nightmare to manage and I want to know if anyone has a simple alternative
depends what you use them for
Iโm working on a IDE for a visual scripting language in a game I play and I plan to use it to filter out what connects to what
Flagged enums in base 2 increments is prolly what you want
Iโll look into it
then you can do stuff like
var validChildren = options.Where(o => parent.ValidChildren.ContainsFlag(o.NodeType));
Sorry Iโm more of an asset designer than a programmer
Iโll have chat gpt explain like Iโm 5 ๐
Flagged enums have a method called HasFlag, basically lets you store multiple possible values in a single value.
So you could have
[Flags]
public enum MyFlaggedEnum {
None = 0, // 0
Foo = 1 << 0, // 1
Bar = 1 << 1, // 2
Baz = 1 << 2, // 4
Phi = 1 << 3, // 8
All = (1 << 4) -1 // 15
}
And you can have a var of type MyFlaggedEnum and you can store multiple of those "flags" on it, like so:
MyFlaggedEnum fooBar = MyFlaggedEnum.Foo + MyFlaggedEnum.Bar;
And then you can do checks if it has one of em like:
if (fooBar.ContainsFlag(MyFlaggedEnum.Phi)) { ... }
+ is not the correct operator, it's |
Wouldn't they both work?
it's also HasFlag, not ContainsFlag
I guess as long as you don't add the same one twice
and it boxes in this version of .NET so it should probably just be done with the full logic
Same dif actually :X
yeah same diff
Oh wait wat lol
TIL
well now I need to go question my relationship with god, thanks XD
Did they change something (or are planning to change something) at some point? Not sure what you mean about this part
does IL2CPP not play nice with flagged enums?
Addition of values and bitwise OR should be different.
not when they are base 2 numbers. 2 + 4 == 2 | 4 etc etc
but TIL you cant + flagged enums, I swore you could
Check the overload for the add operation.
What overload
the what
it literally doesn't compile, because it's a dumb thing to be doing
I'm assuming there is else it's simply addition. Ah, flags, not integers..
now Im gonna make a custom static overload purely to spite you!
Not even sure you can
dang, you really cant
hey
Then it should work let me know if it
General question.. I'm using unity's starter asset pack and it's example third person controller. Is there any reason unity devs decided to use Physics.CheckSphere for the ground check if the charactercontroller component already provides a isGrounded?
Presumably for more control with physics layers and positioning
what is it called when you do what he does in the picture on the right?
and while I am here, does doing so help with making variables accessible outside of a script or does it even matter?
What is he doing on the right?
making the data visible like that
Serializing it?
ok so that is what I need to learn how to do
where do I see serialized data? I swear I have tried to find the answers to these questions on google
in the inspector?
inspector of the script or of the object that contains the script?
The instance of the script that is on an object.
I don't understand this. I pass that power prefab but later it is null
public GameObject powerupPrefab; // Assign the prefab in the Inspector
[SerializeField] private AudioClip pickUpSound;
public void RaycastEquip(FPSController controller)
{
if (controller != null)
{
controller.ApplyPowerupEffect(powerupEffect, powerupPrefab);
Destroy(gameObject);
}
else
{
Debug.LogWarning("FPSController parameter is null.");
}
}
}```
Did they change something with
Cursor.lockState = CursorLockMode.None;
in newest unity versions? It wont stay with lockstate none it will change to Locked after one frame
this would indicate that you are changing the lockstate next frame. maybe in some other code
nvm i had other code breaking it
guys why is this [ExecuteInEditMode] not working?
You didn't save?
saved
still
https://docs.unity3d.com/ScriptReference/ExecuteInEditMode.html
It says you need to put it on the class, not the Awake function?
but i want it run on awake only
Well, then I guess you need to do something like Application.IsPlaying check in the functions you don't want to use it in. 
would this work? i wanna wait a certain number of frames then call callback
but also please add in some protection against running a delay of 0 frames. Your program will freeze if the IEnumerator never yields
frame related
how can i force limit fps from one camera?
ChessPiece cp = PhotonNetwork.Instantiate(piecePrefab[(int)pieceType].ToString(), transform.position, Quaternion.identity).GetComponent<ChessPiece>();
^ This line gives this error -> DefaultPool failed to load "Rook (UnityEngine.GameObject)". Make sure it's in a "Resources" folder. Or use a custom IPunPrefabPool.
What i understand is, that the prefab name is not coming of right. How do i make it work?
This is the full spawning function -> https://hatebin.com/zeecfqhbdp
PieceType is an enum
nvm solved it
guys
i have a question
_attachments = item.ItemData.AttachmentSlots;
this mean i set value from item.ItemData.AttachmentSlots to _attachments right?
or am i wrong?
because whenever i edit something in _attachments it also edit item.ItemData.AttachmentSlots
What type is AttachmentSlots
the same
ye list
oh
How do I play a sound effect whenever a ragdoll limb collides with another object? The biggest problem that I'm facing is that my ragdoll manager is on the player, which uses a character controller, so I don't think OnCollisionEnter would work.
I need a way to check if the colliders of the limbs and such collide with other objects whilst the script remains inside the main player prefab.
use layers
layers and Physics 2D
I'm doing this in 3D.
i meant Phyics 3d
Well, I have no idea what you mean by "layers".
oh wait
No, what I'm saying is that I want my script (which is connected to my player prefab, which contains a character controller, not a collider), to detect if the limbs collide with other objects, layered or not, so that it can execute code upon collision.
oh
have you try OnCollisionEnter yet?
That's the problem that I stated earlier, is that my script is attached to my player prefab, which has a character controller, not a collider.
So OnCollisionEnter wouldn't really work at all.
in collider
The limbs? The environment?
and the turn trigger collider on
limbs
trigger collider will go through object
No, there are no trigger colliders.
or you do this
public class CollisionDetection : MonoBehaviour
{
public float collisionDistance = 1.0f;
private void Update()
{
GameObject[] otherObjects = GameObject.FindGameObjectsWithTag("Obstacle");
foreach (GameObject obj in otherObjects)
{
float distance = Vector2.Distance(transform.position, obj.transform.position);
if (distance < collisionDistance)
{
Debug.Log("Collision detected with: " + obj.name);
}
}
}
}`
Hi guys I'm a beginner in programming and I need a hand with the movements for the player (which is a rocket) in an Endless runner game that I'm developing to learn.
The game is split into 3 low lanes like SubwaySurf, and another 3 high lanes
The problem I encountered is that in the 3 low lanes the Player Object goes to the extreme points without passing and stopping in the middle lane, so it is practically impossible to stay in the middle lane.
An example:
The three lanes are (-1, 0, 1)
If I'm in lane "0" and I click the "A" key, the player switches me to lane "-1" (the one on the left).
Now that I'm in lane "-1" I have to go to lane "0" (might because there is an obstacle), and this is where the problem occurs, instead of going to the middle lane (0) I go straight to the last one lane (1). And I don't understand why. Can you help me if I send you the code?
tick the "Is Trigger" Box
But then everything will go through the environment.
i mean normal Collider
using UnityEngine;
public class CollisionDetection : MonoBehaviour
{
public float collisionDistance = 1.0f;
private void Update()
{
GameObject[] otherObjects = GameObject.FindGameObjectsWithTag("Obstacle");
foreach (GameObject obj in otherObjects)
{
float distance = Vector2.Distance(transform.position, obj.transform.position);
if (distance < collisionDistance)
{
Debug.Log("Collision detected with: " + obj.name);
}
}
}
}
I meant with anything, layered/tagged or not.
you just need to modify that
bruhhh
?
I'm trying to make an open-world game.
Guys i need help pls
My player prefab not only has a character controller, but it's what stores the ragdoll managing script, which is where I want it to detect if the limbs collide with anything so that it can execute code. More specifically, play audio clips.
I need a hand with the movements for the player (which is a rocket) in an Endless runner game that I'm developing to learn.
The game is split into 3 low lanes like SubwaySurf, and another 3 high lanes
The problem I encountered is that in the 3 low lanes the Player Object goes to the extreme points without passing and stopping in the middle lane, so it is practically impossible to stay in the middle lane.
An example:
The three lanes are (-1, 0, 1)
If I'm in lane "0" and I click the "A" key, the player switches me to lane "-1" (the one on the left).
Now that I'm in lane "-1" I have to go to lane "0" (might because there is an obstacle), and this is where the problem occurs, instead of going to the middle lane (0) I go straight to the last one lane (1). And I don't understand why. Can you help me if I send you the code?
can you send a clip?
Ok
and send the code
and send in an dm
That sounds like a coding issue there, u might have inputted the d key as a constant change to the 3rd lane, 1. Ull have to use adding and subtracting in this case
๐ Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
Ok thanks
However this is the clip
Yeah I think I see the problem
Yeah
hello, is there a way to force particles to interact with every trigger, not just the ones in the trigger module list?
I basically want my bullet to detect when it is inside a collider
Also, if there is a better way to do this (maybe without these modules), pls tell me.
private void Update()
{
if (keyPressedA == true && transform.position.x > -1)
{
float targetX = Mathf.Clamp(rb.position.x - moveUnit, -1, 1);
rb.MovePosition(Vector3.Lerp(rb.position, new Vector3(targetX, rb.position.y, rb.position.z), rocketSpeed * Time.smoothDeltaTime));
}
if (keyPressedD == true && transform.position.x < 1)
{
float targetX = Mathf.Clamp(rb.position.x + moveUnit, -1, 1);
rb.MovePosition(Vector3.Lerp(rb.position, new Vector3(targetX, rb.position.y, rb.position.z), rocketSpeed * Time.smoothDeltaTime));
}
}
had the same problem so here
@celest canyon
Now i try change it
er, use a script?
I tried to change the script but it's the same thing
ok
here
private void Update()
{
if (keyPressedA == true && transform.position.x > -1)
{
float targetX = Mathf.Clamp(rb.position.x - moveUnit, -1, 1);
rb.MovePosition(new Vector3(targetX, rb.position.y, rb.position.z));
}
if (keyPressedD == true && transform.position.x < 1)
{
float targetX = Mathf.Clamp(rb.position.x + moveUnit, -1, 1);
rb.MovePosition(new Vector3(targetX, rb.position.y, rb.position.z));
}
}
Ok
You mean populate that list with a script?
It would be nice to have a "world" flag, just like in the collision module
I guess there's none
yeah i looked again you need to make a script
you can useprivate void OnTriggerEnter() and Exit
you mean ```cs
private void OnParticleTrigger()
{
}
yeah
did it work?
No it's the same thing :(
๐ฆ
It makes the movement even less smoother
Because to not make the object teleporting from one line to another i need to use the Slerp() function but a slerp function needs more than one frame to work
That's why i don't simply use the input from a Key
you could use Input.Getkey.... and use Timeline to make it smooth
Because when you press a key, the Slerp function to move the rocket doesn't work, so i created a bool for each key (WASD) and after some time it return false
Ok i'll try
btw timeline is like animation so it will take time
Alright, sorry about my inactivity. Quick medical issues and an overwhelming crowd inside this channel.
Not yet.
do you use colliders in the limbs or not
Yes.
Because the so-called "collider" is a character controller.
I'm just trying to figure out how to detect the collision of all of the... Screw limbs, I'm gonna say bones now.
Yeah, it's kinda complicated.
And that's why I'm asking for input.
What was the question?
I'm trying to make a script where it will detect if the bones' colliders collide with other objects of any kind, and then execute code whenever it does. The problem, however, is the fact that my character is the player which has a character controller component instead of a collider/rigidbody component.
There's a separate physics message for that
Okay.
Okay
So, what do I do?
I'm basically trying to detect collisions within children of the script's GameObject.
Children colliders will still send messages to a parent if that parent has a rigidbody. Not entirely sure if CC follows the same logic but worth a test
I've tried testing it. Nothing happened.
Not even the Debug.Log functions worked.
You might want to use some kinematic rigidbody then and just use those collision messages
Yeah, but at the same time, it's a ragdoll. Ragdolls can't be kinematic.
If it's a ragdoll, then your bones have rigidbodies and colliders.
Just put a script on the limb and use the collision message
I'm trying to do this with every limb because the script I'm talking about is a ragdoll manager which holds all of the code for the ragdoll.
Adding a script for just the impact sound effects for every limb is not only time-consuming, but also inefficient.
You can mass add scripts by just selecting all the limbs and adding at once
Like I said, that's an inefficient method.
Inefficient in what sense? All of your limbs are already rigidbodies calculating their own physics forces, this is already inefficient by your standards
They're all calculating their own physics forces because it's a ragdoll!
Put a script on your limbs then to call functionality on your main script when collisions happen
I know how ragdolls work, I'm making a game based on active ones. I am informing you that you already have scripts on every single limb, which by your logic is inefficient.
Because I think it'll cause performance issues.
Ok and you can think that, but you havent profiled it and seen any performance issue
Hello!, I'm looking to learn C#,do you guys have good tutorials?
Btw I do have previous programming knowledge about 2-3 years
@summer prairie I guarantee the performance cost of doing this is nothing in comparison to the work the physics engine is doing to calculate your joint forces
I recommend w3schools if you want an interactive website to help you get the syntax down.
Ah okay. Thanks!
why the hell not :)
ive got an ICollection of strings
i want the first one
why cant i just do [0]
Also are there any tuts on Unity C# since iirc they're a bit different.
Why are u using ICollection if you want indexing, just use list or array
Yes the unity !learn site has a lot
๐งโ๐ซ Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/
not by choice!
not gonna go into it, its not important
Gotchu.
I dont recall exactly if this works but try using linq then or foreach to loop over it and just return the one you want. In this case just the first
this is general coding, you should know that ICollection only has a Count and IsReadOnly property. you cannot index an ICollection; if you need to access an element use IList instead . . .
also, c# is the same in Unity (not updated to the most recent c#), the difference is from using the Unity API to write your code . . .
Hello, so I opened up my project today and VSCode seems to have updated a plugin breaking all intelisense. I saw that there is a new VScode Unity plugin, so I deleted all the other Unity plugins and followed the instructions found here https://code.visualstudio.com/docs/other/unity .
Intelisense is now working but I have errors all over the place in my IDE even though it is compiling just fine in Unity. No external packages seem to be importing correctly and even basic functions like FindObjectOfType apparently not longer โexist in the current contextโ.
Has anyone experienced the same problem, or know of any possible causes ?
Iโm not sure if this is because I have something setup wrong or what. As someone trying to learn Unity, having the tools break mid project Is really discouraging.
That's VS Code in Unity for you.
Recently MS took over support so it's probably just initial issues with that https://devblogs.microsoft.com/visualstudio/announcing-the-unity-extension-for-visual-studio-code/
VSCode often breaks (for most people). however, i have not installed the new unity plugin from microsoft. it may have bugs or issues . . .
If you have access to Rider through GitHub student stuff I recommend that
Ig I was wrong lol.
Ok thanks for the lead. It's nice to see VSCode getting some attention but yeah rather frustrating. I don't have access to student offers and paying for an IDE for what I do isn't really worth the expense. I guess i'll just wait for them to iron out the bugs.
my vs code even cant open the project, it just keep "processing workspace information in background"
Can't you just roll back the package?
After my vs code automatic update to 1.81 then all the stuffs are broken, even reinstall 1.79.2 doesnt help
Fine, I did the thing and it "works", but now I need a cooldown on the audio, since it plays on every frame that the bones collide with other objects.
aaaand i just killed the chat
What does Instantiate(prefabName, transform) mean? I don't understand why it works cause there's no position or rotation values...
Hello, I have a rolling ball game. Added bumping into objects sound effects.. however due to the nature of the level being separated into several meshes, the sound effects play while traversing from one collider to the other. Looking for a solution if anyone has one, thanks.
You can combine mesh to make only one* collider for the whole road
Anyone got a stomp code i could use? I'm rushing a submission i have. I want to have players stomp on a barricade to get a powerup.
Do you have an idea to remove the reference in Visual Studio Code ๐ง
that's code lens. but why would you want to remove convenience stuff like that?
Thank you for the reply. I came up with this solution.
that's way too bespoke for someone to just have a portable solution for you laying around that works in your game.
Because he take lot place in my scripts
do you just have like hundreds of members per class or something?
but also having it enabled makes debugging a bit easier since you can just click on that to see its references
I am convinced I keep it ๐
hello, not much unity related, but what datastructure would be best to saving data like this, so like dictionary, but it takes 2 parameters, and doesnt care of their order, Like Dictionary<Pair<var, var>, var> is a solution but it cares about the order of pair,
I mean simple way around is just make some rule of asigning them and then ordering by that, for example, the dot with lower x and y value combained is first in the pair always, would do the work, but if there is better ideas i would like to hear them
this looks like an undirected graph from the picture
however for what you described you would indeed just use a Dictionary
just make sure the key has a .Equals and .HashCode that doesn't care about the ordering
oh
true
so i make own class for that
and override equals/hashcode
that could work
e.g.
struct NodePair {
Node a;
Node b;
public override Equals(NodePair other) {
return (a == other.a && b == other.b)
|| (a == other.b && b == other.a);
}
}```
yep
I've done this many times
seems clever, thx
I'll let you figure out the HashCode part
you could also just put everything in the dict twice - in normal and reverse order
I am currently billboarding these sprites in 3D space, how can I rotate the purple sprite to have the north side always face the moon? https://imgur.com/SZLKRFz.gif
there is a gray square on my screen
this is a code channel, mate. but try restarting the editor
sorry, I dunno if we have a bug channel, I already tried that, as well as updating
#๐ปโunity-talk is the channel to ask in when no other channel fits the issue. but if restarting and updating did not resolve it, then it's likely some asset you've downloaded or editor code you've written
hmmm, well, thanks
@strong ravine
that I know, I have a friend that we keep sharing this project with github, he does not have this gray square, so I belive it might be something I need to delete on the assets
These squares come from gizmos bro..
you realize they are referring to the big empty grey rectangle that is not inside the scene view, right?
probably a custom window maybe?
Oh now i see it
yeah probably a window from some asset if they haven't written their own editor code
It could be that you have to select a few more options regarding the *.csproj file generation. (You can find this in the Preferences under the "External Tools" tab.) In my case I currently have the following selected (see screenshot) and it seems to work for me. Also make sure to hit the "Regenerate project files" button just in case.
I sadly had no choice in that regard: VSCode just stopped working, and installing that extension (and upgrading the "Visual Studio Editor" package as instructed) resolved it for me. Let's see if there are any new bugs...
It could be that the C# extension is the problem here. I've heard that you can't really control when extension updates are installed, so installing a specific version might get tricky...
However, a workaround (if you don't want to install the preview Untiy extension) could be to install the Insiders version of Visual Studio Code. I have no idea why, but that one seems to work with the very same Unity projects. (But since it's a separate installation, you'll have to reconfigure everything and reinstall all extensions.)
i downgrade my vscode to 1.79.2 (same as the version shown in picture of the guide) and it is just keep loading on it and i google nothing on vscode keep processing workspace information
i have tried: restart computer/regenerate project/clear all data in .vscode then reinstall it, nothing work, maybe i should try insider
Have you tried the preview Unity extension? That's currently the way how VSCode for Unity is described to be set up: https://code.visualstudio.com/docs/other/unity
yes i use it, and i havent back up my previous workable setting, sad
Very weird indeed. I received the notification for the 1.81 update but declined it. So far I have no problems, but the new Roslyn warnings/suggestions pop-up everywhere . . .
i am using 2021.3 editor it says at least Unity 2021
i notice that the version of his editor on screen shot is 2022.3.1
Thanks that worked ! regenerating the project files did the trick without having to check any extra tickboxes
have you tried to clear extension data?
i delete all files and folders in .vscode and reinstall the vscode then install unity extension.
i havent tried the link you sent, thank
That.
Noted.
Anyway...
I was wondering how to call a function from an object in a different scene, since you can load multiple scenes at once. I have a persistant scene that has a LoadGame function that I want to call upon pressing a UI button, but I can't seem to figure out how to get that to work.
static instance
same as what you do when you want a singleton
Okay, yeah. I should've asked in #๐ปโcode-beginner, because I have no idea what static instances or singletons are.
If you activate a Rider free trial in a sanctioned country like Russia and levae within 30 days, it won't ever expire. I have been exploiting this loophole for well over a year and won't ever pay for Rider to use it legitamately.
Does anybody here use Photon Fusion? I need some help with my KCC setup. Basically I don't know what stage I'm able to change data.kinematicvelocity. Any help appreciated!
I'm having this strange issue with a mesh that I'm baking repeatedly while the Player is dashing to make a trail. I've been following this tutorial here: https://www.youtube.com/watch?v=7vvycc2iX6E&t=1s&ab_channel=GabrielAguiarProd.
For some reason, when the mesh gets baked using the code I've screenshotted, certains parts of the Base Mesh Model (Trousers and Jumper) do not get baked but the Head and Hands do even though they are all a part of the Base Mesh Model and I can't figure out why.
With this Unity tutorial now you can add a cool Trail to your Characters! Super useful for when trying to convey a speed boost or a quick character movement, like a dash. I am speed!!!
I am making a game, check it out: https://twitter.com/GoldenBugStudio
00:00 Intro
00:51 Mesh Trail Script - Start
04:54 Baking the Mesh
08:05 Glow Shader
10:2...
Has anyone tried this method before and ran into a similar issue?
this is not code, but i dont know where to ask, i cant build my game, but when the build fails i dont get more error than this :
Build completed with a result of 'Failed' in 128 seconds (128480 ms)
Building Player failed
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Can ask in #๐ปโunity-talk
Show the full error in the console too
you probably won't waste so much time if you read this question
https://discussions.unity.com/t/how-to-call-a-function-from-a-script-in-another-scene/10853/3
Hello. I am hoping someone can provide some insight for me. I have a web file server that has a folder full of OBJ files and JPG texture files. I have a simple unity scene that I have built for WebGL deployment, which is embedded into a .Net web application. I would like to be able to dynamically load the OBJ file from the web server as well as the JPG texture file. I've had some luck using https://assetstore.unity.com/packages/tools/modeling/runtime-obj-importer-49547 to load the OBJ file but I can't get the JPG file to load with it. Are there any tools (free) that I could use to accomplish this?
Would I need a library for this? Or can it be done without something like the obj importer?
asset bundles?
If I wanted to do something like store an object's local position only while in the editor, how could I do that? Im thinking something along the lines of fetching it in "OnValidate" but im not sure how to make it not occur while the game is running.
Not sure I follow?
explain the "store the position" what is the use case
You can use a Scriptable Object to store Vectors. This is a serializable object that persists even after the game stops
unity can load asset bundles, packed assets, you can pack any model you want into it and load at runtime
doesnt need to be any specific format
bundles can pack shaders, materials, whatever else, all you need is the infrastructure to pack and load
Can this be done dynamically? All I have access to is a file server with OBJ and JPG files. I have to load them into the website webgl unity scene when the page loads
Well, I would like to keep a rigidbodie's original position relative to its parent transform while it moves dynamically. Storing the position only while editing so I dont need to make it the child of another object just to access its local transform.
thats not your server?
No, I can't touch the web server. I can do web request to load the files
would a position/parent constraint work for you?
yeah then use whatever library you find that works for you, there is no standard way of doing it
only good thing about your situation is that obj is so simple you can write importer yourself pretty fast
unity already can decode jpgs
oh damn, I think that could work, thanks
Yeah, there is an obj import I was looking at, but I dont see how to include the jpg file. It seems to expect an MTL file? https://assetstore.unity.com/packages/tools/modeling/runtime-obj-importer-49547
Do I have to dynamically create a Material and assign the JPG to it?
should come with obj
obj+mtl is the standard package
obj describes triangles/etc, binds material to triangles
references mtl's
mtls describe material and which textures it uses
test it
open the obj in notepad, find any material name it uses, try getting that mtl from the server
should be in the same dir as the obj
if it works, you can automate it, scan the obj for materials, load them from server, load textures it references
if there is none, maybe it is assumed one texture per object then you can use any material with that texture, maybe
refer to the server docs if there are any
im looking to add a jump pad feature and the charactercontroller isnt designed to use a rigidbody would there be an easy way to detect collision to just change the jump height and call the jump itself rather than on key pressed with like with raycasts? like in my queuejump method an if statement to detect collision with something specific
is anyone familiar with best practices for representing a 2d gridded space with edges? I'm working on a project that involves a large square gridded map and both grid spots and the edges between them would need have information stored about them: A tree would occupy a grid spot making it untraversable and a fence might sit on the edge between two traversable grid spots disconnecting them.
An obvious choice would be a connected graph but this seems utterly too complex and hardware intensive so my initial thought was to simply have a 2d container of grid spots and have each grid spot keep track of the information for the edge north of it and to the east of it, if im missing some better solution i would be thankful for some help and if you have any clarifying questions feel free to ask.
if i understand your code correctly you might be able to add a downward raycast to check to detect a jump pad object below you and queue a jump with a special boolean flag that marks it as a jump pad jump
what would the detection part look like
you would want to use the Physics.Raycast() method found here, this would return a bool to whether the ray collided with an object, this could be used to trigger an m_JumpQueued in another if statement like you have. Some tips i would suggest are to 1. place the start of the Ray as close to the bottom of the character as possible 2. make the Ray distance quite short so that you only trigger this when the character is right on top of the jump pad 3. assign the jump pad object to its own layer and specify that the Ray should only collide with that layer so that it only returns true when colliding with a jump pad you should be able to find very comprehensive tutorials online for all of these things, as Raycasts can be kind of confusing to figure out for the first time
would the start of the ray be defined using a float value near the ground or would it reference a camera placed towards the bottom of the character
Iโve seen versions where they use a cam on the bottom of the character to see if itโs in line with it
you could create a child empty object to the character that is at the position you want the ray to start at and reference it or you could simply represent it by the characters position plus or minus some vector 3 offset that places it near the ground
i dont think a camera itself would be needed
having an empty child object is more convenient IMO because it allows you to visualize that position in the editor
alright Iโll give it a shot
i cant seem to find a down direction for a Transform object
i guess i can just rotate it downward
Not sure if this is the correct channel to ask this question, but I noticed that a few days ago the Splines package #2.4 was released. I'm in editor version 2022.3.6f1, not sure if that package release is in a pre-release editor version?
The first question is: is there for sure a need to be able to dynamically change these files without having to re-deploy the webgl project? Or would "if we wanna change the files, we need to redeploy the application but in return the application is way way more performant" be acceptable
cuz dynamically loading those files client side is gonna add a pretty heft chunk of load time to the webpage tbh
ok so i set it up like this but its not initiating a bounce am i referencing the layer wrong?
i found that if i remove all c# sdk then my vscode will not stuck in loading project (processing workspace in background) but instead this pop up:
and no intellisense
am i the only one randomly having issues with vscode giving unnecessary warnings like saying the start function is unused etc
I've been seeing that complaint a LOT lately (6 people in a few days). So, no, you aren't the only one
i see, that sucks
Not sure what, if anything, fixed it. Sorry
my vscode even not working maybe i should report it as bug
Someone said there was a recent update? Maybe that broke something
They're rolling out a Unity extension for VSC, in preview
yeah i presume its related to the new extension
installing it didnt seem to fix anything though
The installation instructions are easier, but they're different nonetheless. You need the C# extension, and in Unity the Visual Studio Editor (not Visual Studio Code Editor) package
VSC Editor package will be deprecated soon, because VSC doesn't need it anymore with the new extension
maybe ill just give up and use the free rider student license i have xD
it says install the unity will automatic install all dependences, you just need to install the ms unity extension
if you have Rider Idk why you'd bother with VSC
Rider is waay better.
only issue is the license doesnt apply for commercial games
but i think i found the fix, just need to downgrade the C# extension version to before 2.0
and uninstall the C# dev kit and unity extension with it
(thats how you can install an old version)
Just to be sure: you not only installed the Unity extension, but also upgraded the "Visual Studio Editor" and also regenerated the project files, right?
Custom keybind manager
I use Rider mainly, but recently I've been using VSCode a lot more. It's kinda nice sacrificing a lot of the intellisense speed and debugging support in favor of extremely fast load times and fast project-wide searchs of either text or tokens (such as classes or methods). My main complaint with Rider is how slow it tends to be for me on project-wide searches, so when needing to constantly bounce between closed files or to find a certain method quickly, VSC makes that nicer imo. If I want debugging and stuff, I'll still use Rider though.
yeah i did, shouldโve mentioned that
I don't know how much depth your world has but I build worlds using a matrix class I created that might be semi similiar?
I have this on a grid
Excuse the really bad paint textures, they were just solid colour materials for testing
With this I'd have a similar approach to what you mentioned but I wouldn't have the cell containt information on what is around it... it would just contain what is inside itself and then the cells know where they are
Well in my system the cells actually don't know... the chunks handle that
you are using navmesh there?
I... have not been working on AI yet, I plan to start on that in the upcoming weeks which does scare me indeed lol
the original question is about pathfinding graph
I may slightly misunderstand but with a 2D grid with more linear movement you can use A* Pathfinding with the 2D grid using the method I mentioned but if the "Graph" thing is a package or something then I might be wrong
Because you just grab the cell to see if it's valid using that method, a bit like how Rimworld pathfinding works?
the question as i understanding it is - "i want to avoid using a massive connected graph with each connection represented as reference because it seems not performant"
Well, I don't need to load the objects at run time. When the web site that has the WebGL app loads, that is fine. But, I would want one scene that I can use that would have basic functionality (lighting, camera setup, UI, etc.) and then depending on parameters being sent to load the website, have a different OBJ Model/Texture loaded.
It depends how many things are using it, how many cells you have / size and etc because I don't believe it's that bad?
my thoughts on it - depends on the size of the map, even with value based structure you will still hit a ceiling after which you will need conceptual shift to optimize large queries
rimworld segments the world into regions, and long distance paths use different greedy algorithm that approximates a path
Rimworld did a region system I believe? Where it made bigger blocks and checked if they had connections to other blocks and then if they had a connection, it would then go inside that block to pathfind
Yeh, that's it lol
I am no expert in this though tbh... But there isn't really other ways of doing it?
The unity Navmesh does it the same way I believe? A bit fancier but it splits the mesh up into tri's and pathfinds using them as the blocks for A*?
navmesh is less dense
generally its so much sparser you have less issues on large maps
I need to figure out how I plan to do Pathfinding on my game tbh
yes
start with navmesh
World changes a lot, I need a way to load the chunks and generate the navmesh which I think the experimental package does
Assuming it works with all my cells
Worried it might be quite expensive because of all the seperate floors
Floor is a lot of these
Chunk
It stresses me out honestly, I really am unsure about my approach
unity navmesh is chunked by itself already
you can control its tile size and only rebuild the tiles containing changes
I'd need to look into it then, if I can have a Navmesh chunk the same size as my chunks with the same tiles, that would be optimal
That being said... I was thinking of loading in the navmesh chunks when my map chunks loads, if Unity can automate that then I shouldn't have to worry about any of that?
the only issue is that you will most likely need to build your own agent, default agent is very limited
loading in chunks?
simplest is to build it once, update on change
its still going to be there
switching on off anything should not affect the navmesh
Yeh I thought it would but from what you've said, I guess it might not be an issue
5x5 units
The bulk of pathfinding will be short distances anyway because AI that go outside of the rendered 3x3 chunks will just finish their current path and if they aren't back in a loaded area will just disable
The pathfinding won't be rebuilt that often if I can prebuild it...
I just thought I would have to build it in game every single time I go into a new chunk
actually
you may still need the grid anyway
missed the fact you need to extract data from environment
enclosed spaces, flood fill searches, etc
but at least the pf will be offloaded to navmesh
You seem to know far more about this than me ๐ I only know a little bit, I hope I didn't appear more competent than I am haha
same
One thing I need to really think about implementing is how I am going to calculate rooms and houses automatically
why is this particular scene pink?
But maybe the Rimworld dev logs somewhere can help
you flood fill
The background shader is probably incompatible with what pipeline you are using
At least that would be my first guess
Nvm got it to work
thats all there is to it, you create a general use fill function, you customize it by providing selector/predicate/any logic that should analyze the tiles
So do some reading up on "flood fill" is my take
When you put down loads of walls and eventually create an enclosed space yes
But thinking about it... I could probably trace the walls if it's connected on both sides, follow it around to see if it links back up with itself
never tried this approach
Well I've not really heard of flood fill but I can take a guess at what it does
I'll have to look into that because it might be better
same as BFS
but you dont search you instead visit tiles and analyze them for properties you are interested in
in your example it can be, "if there is a tile that doesnt have ceiling above it - we are outside, so the room is not enclosed, so abort fill , this is not a room"
hahaha
Oh man... I need to sort roofs out
๐
That actually might be the best way to do it
Building isn't automated so the roofs need to be placed but my whole world is just 2d currently, no levels... I need to figure that out too and it pains me
I think the roof approach is easier but less accurate
Yeh... I think I might shift my focus to making a house in general, figure out a way to define things as rooms, allow building a 2nd floor and etc
In general every cell is independent and only holds information on itself, there is no real grouping of any sorts other than chunks.
I need to figure out how I want to store information like "Rooms" and how the cells will link to it
@ashen yoke I'll do some reading on the flood fill and thanks for the insight / help
appologies, i was afk for a while, the depth is very limited in comparison to this example as there is no map making component, and movement is very discrete between single cells (pathfinding would only be needed for AI and i was planning on using A*) in your example, is movement continuous or discreet? essentially i need my code to be able to determine if movement from one cell to another is valid based on both edge and cell barriers
I'm using an audio mixer for the first time in order to pitch shift audio that has been sped up so it sounds normal. That's all working fine. I have an array of clips and I set the clip for the audiosource based on a selected clip. After that clip has played, you can select another clip and play that. Without the mixer, this works great. With the mixer, the 2nd and subsequent plays play a bit of the previous clip first. At the end of each clip I do a Stop() and at the start I set .clip = null then set .clip to the next clip. If I remove the mixer from the audiosource, it works, if I add it, it plays a bit of the previous clip. I'm not using the mixer for all audiosources, I have audiosources all over the place for buttons and whatnot. I feel like I must be missing something obvious. I've looked for a way to "reset" the mixer to no avail. Any clues/ideas/suggestions very welcome.
I found one thing that works, but..... if I do AudioSettings.Reset() there's a slight delay running it, but the sound artifact goes away. Feels like using a sledgehammer to kill an ant though.
My game will be continuous but I haven't done the pathfinding just yet on it
My cells are made up like this
public class CellData
{
public FloorData floor;
public WallData[] walls;
[CanBeNull] public ColumnData column;
public List<PropData> props = new ();
}```
so each individual square has its own walls
ah so it is similar to my concept
my old original one there was 4 and it was such a pain determining where the walls went... I also had to check neighbour cells to see if I was replacing it or if it already existed on neighbour and etc
So yeh probabily similiar to yours
1 floor, 2 walls, 1 corner
thanks, i feel much more confident in the implementation i have now
It just felt like the most logical approach
The only issue you get is that the the furthest top and right edge can't be populated
Of the entire map
yea, ive basically accepted that once i get to proc generation ill have a one tile border around the map
Well my chunk system helps with that
It just gets the next chunk on the corner but if you have a more static map just make the one tile border invisible, it's a cheap fix but players won't notice
The other solution is logic specifically for the end but I think it's more work than it's worth, better invested elsewhere
yea, im hoping to implement a kind of wave function collapse as an easier method of proc gen and my maps will be relatively small 100x100 as a maximum size so hopefully those wont me major issues
If you are doing proc gen then it'll honestly be very similiar to mine then
How do you access tiles? Have you got a grid class to handle it?
Or do you just have an array by flattening the Vector2?
i havent really started the implementation as i was planning this aspect out first, but i expected to have a map class that contains 2d array of scriptable objects taht each represent the tiles
I see, so your tiles are going to be predefined
yea, the static content of the cells will either be designed in a testing map, or eventually proc generated before play, entities will be able to move through tiles though
I won't pretend to know a lot about pathfinding, I did some fundamentals a while back in uni so I can't guarantee this is the best advice but to your original question, what do you mean by a "Connected graph"?
Is that like caching A* results?
when i suggested a connected graph for storing the data thats the easiest way to think about this grid in a literal sense because it is nodes connected by edges so you actually have a place to store the edge information that is the edge itself
the idea being that if i stored the map data in a graph that "looks" like this
if i wanted to represent a wall in code
i would flag that edge in the graph as a wall
but iterating through a graph is taxing and its hard to access a specific part of the graph intuitively
so in the above case each circle is a cell and the lines connecting them are the edges between
I think adjacency matrix might be wrong for that case...
But if you did a region based thing it might be useful to see if places are reachable
yea thats true
So there are multiple factors to see if you can go on a tile?
Like for instance the floor type, the edge? What's on the tile?
yea for example, the tile itself might be totally blocked cause there is a tree occupying it, or the edge between the tile you are on and the destination has a wall or fence on it
in either case you cant move from the tile you are on to that tile
If there are multiple factors you could save on computing but take a bit of memory if you do precalculate these and put them into an index like that
yea, listing for each tile, you can go up, down, left, but not right might be useful
depends on the compute time and the map size i imagine
Are you going to store these as an array of bools with a quick lookup?
For consistency when it comes to numbers I start from down and go clockwise
0 = down
1 = left
2 = up
3 = right
And I use that for everything
cell.validPath[3] for instance
yea thats probably how i would do it
But you do get a lot of duplicate data then
if i really wanted to be efficient i would calculate at run time if the path hasnt been traveled and then store the result for future
Maybe but I wouldn't worry too much about that to start with
Each cell is stored as what?
i was planning to write a scriptable object to store them
1 SO for each tile?
i dont think i need a fully fledged class but i might need one
a SO is still a c# class..
i'm getting this weird behaviour and I can't explain it. I have set all of the values in the inspector as well
I just run my script and nothing is actually interfereing with it
code dies here
It just depends why you want to use an SO?
is there a significant difference in choosing lf or crlf line endings for unity projects?
i think thats just waht im used to using but in hindsight its probably just best to use a normal C# class
The stuff I can spawn are SO's because they all behave and interact with the world in a similiar fashion
But my Matrix and Cells use classes with polymorphism
SO is good for things like this
SO might be suitable for your tiles as they are predefined... it really depends
You can see the line numbers but we can't... I am not sure where you mean this error is occurring. It is your spawnPostions[randPos] ?
bruh wtf, i found the problem
somehopw
idk how the fuck right
the camera had a game manager script
so the singleton was wiping my array
smh
what do you mean? where do you even get to select the option as a choice 
if you're referring to something when pushing to version control, then please specify
Sorry sometimes it's difficult because I get a bit tied on my thought process for my game, my cells have a lot of autonomy but in your case I think you just get the world to create the map 1st and then have it loop through each cell to evaluate the link connections and on each tile set the bools in the array for if it is a valid movement.
Sorry for the long discussion for your question btw lol
Or you can create a 2nd grid which only contains the bools of where it's allowed to go.
Personally I'd have it on the cells because it means I can just grab the tile and have additional info if I need it... Like for instance if you have certain units that can bypass certain things like fences
no worries, i think at this point its most valuable for me to start implementing some of this and see what sticks, cause atm this system exists only in my mine lol
I have an idea for you
Instead of bool, store your allowed movement as an int for each direction
0 = can't move
1 = can walk over
2 = can jump over
3 = can fly over
Depends on your game... just a random idea if you wanna do stuff like that ๐
yea thats good, cause i will definitely have flying units in the game
thanks for all the advice, i have to run to the store so ill be afk again
Yeh so have something like... movementLevel on the unit and you just check directions to it's movementLevel to get allowed directions
Alright! np and gl!
ty!
well for me i'm using .editorconfig and there's an option to choose how to format documents with either crlf or lf with the end_of_line property
it probably shouldnt matter, i believe unity uses lf but if you push to git itll say its converting to crlf anyways and that hasnt broken anything when pulling
What's the best way to animate sliding doors to open on player proximity? Do the actual doors need to be different meshes to the frame?
I would make the doors a separate mesh than the frame, that way you can update the transform, detecting the "proximity" you could use a physics cast or trigger collider as common approaches
Could it be in a prefab with the outside frame? Then a script to constantly check player distance?
You probably wouldnt want every single door constantly calculating the players distance. Have a trigger area that just does something on trigger enter and exit
Trigger collider component.
Yes, it can be on prefabs
Or a child with a trigger collider if it's off to one side or something
ty
Sorry, when working in 3D, what component do I need to add
Sphere or Box collider. 2d ones say 2d at the end, 3d ones say nothing at the end
ty
And also, of course, spheres and boxes are 3D shapes
Does anyone know why ```cs
Camera.main.WorldToScreenPoint(worldPosition);
JumpHeightBuff, Assembly-CSharp (1 object)``` Anyone have any idea on how I can fix this?
Ohhh i see. It was a Scriptable Object. And it was null for some reason when I opened unity. Strange
ยฏ_(ใ)_/ยฏ
How do I then stop the player actually not being able to pass it as a rigid body?
Oh, "Is Trigger" I assume mb
I now have the colider set up, I have it set the door scale to Y 0 on enter, but it's a really sudden jump to open - how can I animate the door opening?
JSONUtility creates a default instance of an object, then populates/sets each field as it reads the json file when deserializing?
And the [OnDeserialized] attribute makes that function get called afterwards?
public Animator theAnimator;
theAnimator.Play("open");
Create animation and controller. add controller to the door parent
does anyone know how to fix this so it has collision
if(Input.GetKey(KeyCode.W)) {
transform.Translate(Vector3.forward * Speed * Time.deltaTime);
}
if(Input.GetKey(KeyCode.S)) {
transform.Translate(Vector3.back * Speed * Time.deltaTime);
}
if(Input.GetKey(KeyCode.A)) {
transform.Translate(Vector3.left * Speed * Time.deltaTime);
}
if(Input.GetKey(KeyCode.D)) {
transform.Translate(Vector3.right * Speed * Time.deltaTime);
}```
Collision as in? If you mean the character itself, need to add a capsule collider - not code
no that does not work i have had that for a longtime
This code wont care about collision because you are never checking for it. You'll want to do things like raycast to see how far you can move
Then when your raycast hits something, you now have the max distance from the raycasthit variable
so i do a ray cast in the dirction you are moving in at the length of speed and if it hits then touchingWall = true?
Well theres a LOT more that goes into making a proper character
You could use KCC on the asset store
!code
๐ Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
i tried this and it does not work
๐ฎโ๐จ out of all the possible ways to write this, i could have never expected this
you should look at some basic movement tutorial
there are hundreds, and they 100% cover this
how would you do it