#💻┃code-beginner
1 messages · Page 167 of 1
using UnityEngine;
public class WaveManager : MonoBehaviour
{
private static int numberOfWaves = 0;
public GameObject zombiePrefab;
void Start() => SpawnZombie();
void SpawnZombie()
{
Instantiate(zombiePrefab, transform.position, Quaternion.identity);
numberOfWaves++;
Debug.Log("Wave " + numberOfWaves + " spawned!");
}
}``` @grizzled pagoda
yea, i think i'd use a master script that u can count the waves on..
but events could be cool too.. u would subscribe to an event like (when u spawn a wave or w/e)
then anything subscribed (listeners) will fire off their respective functions when it happens..
this could do things like count.. or add to a number for example..
even when its not in the same class..
thats odd, i cant replicate the bug. That should be a compile error anyways so it should light up in the IDE. Maybe it is using a different Sound type
yea that's what i thought at first
that there was some ambigious reference when i used the name Sound
// UnityEvent to signal when a zombie is spawned
public UnityEvent onZombieSpawned = new UnityEvent();
void SpawnZombie()
{
Instantiate(zombiePrefab, transform.position, Quaternion.identity);
onZombieSpawned.Invoke(); // invoke the event
}```
```cs
using UnityEngine;
public class WaveCounter : MonoBehaviour
{
private int waveCount = 0;
public WaveManager waveManager;
void OnEnable() => waveManager.onZombieSpawned.AddListener(IncrementWaveCount);
void OnDisable() => waveManager.onZombieSpawned.RemoveListener(IncrementWaveCount);
void IncrementWaveCount() => waveCount++;
}```
heres a boilerplate example of how using a unity event would work.. (altho im not super familiar with unity events just yet)
Also zombie should just have event OnDied , that spawner subs to
very well coulda been, having it exposed in the editor might trigger something where unity can clear up any confusion
I swear I have no f idea why, but it seems assembly definitions are to blame. I've had 2 folders with scripts and 2 assembly definitions, one pointing to another one, and suddenly when I deleted both assembly definitions everything started working when I build the game @wintry quarry@rare basin no errors, no exceptions, my Card class spawns properly, everything works fine after I build the game and it's all because of assembly definitions
if I've had misconfigured assembly definitions then why did they work in play mode before building the game out?
I have no idea but this is what it is...
And definitely there was no issue with #if UNITY_EDITOR or my custom Auxiliary.cs class
this
I don't usually do this, I actually just have a bunch of audio sources for each sound effect
don't like it but it's how it is
that works, i usually use 1 source for each type of sound.. 1 source for all the gun sounds, 1 source for all the button clicks, etc
PlayOneShot() can play like 3 clips at a time or something
👍 keeps it pretty simple to debug and keep track of everything
unity needs a better sound system honestly because it's not very intuitive
eh, once u use it for a while it gets pretty intuitive
its when you introduce a mixer and multiple sources it does get a bit complicated
ohh and the way the spatial audio works.. (3d audio) getting the settings correct for the audio to fade when u walk away from it..
that bit took me a while to get going the way i wanted
THE MIXERS I like
fw the mixers leave those alone
but the line setting up idk
I like fine tuning my sounds perfectly
so that does require having sources for each sound effect
i might try and make a sound engine and see how that goes
Yeah, this seems like a simpler version of my code, though my code checks for the amount of zombies, and then spawns the next wave
Why do you ping me, don't
Because you were involved in the case? But fine
help! why my animator wait for end of animation for do the transition?
uncheck "has exit time"
on all animations that should be interruptible by other animations
otherwise the animation can ONLY be exited at the set exit time
also next time #🏃┃animation would be your channel
I copied the scripts and didn't have an error. I think they didn't save after adding the source line . . .
cool cool ur 2nd one to say it wasn't replicateable
dont work :\
Oh, I see they had an ambiguous exception. Not sure how they have two Sound classes . . .
One of them didn't have the source field . . .
ahh yea makes sense.. ghost code
I use SOs for sounds or an array of sounds an object will use, but I have a list of audio sources for each type of sound, similar to SpawnCampGames. It's much easier to use with an audio mixer (they're awesome when setup correctly) . . .
how do u tune ur audio? @cosmic dagger ?
like do u keep the audiosources at 1 volume
and tune it down in the mixer?
thats the only problem i seem to have.. like where to start my audiosources volumes
Yep. All the audio sources at 1 by default . . .
that's what I was thinking of just now!
@wheat geyser
So, e.g., I have an SFX audio source attached to the SFX mixer. Within that mixer are multiple audio mixer groups for different types of sounds: projectiles, footsteps, ambient, etc.
I set the volume for these groups in the audio mixer. So footsteps will be lower than projectiles, but the actual SFX mixer will come through at normal volume
This allows the user to still control the volume for music, SFX, dialogue, UI, etc., from the menu . . .
damn bro why u flexing on me like that
lol no flex, its more procrastination
the menu looks real sexy though
thanks if u got any questions about it i'd be free to answer
but its basically a parallax mouse script and JSON save system in the backend
Will keep it in mind but haven't given menu's a shot yet so far in my project :))
Yeah i'm sure its nothing too complicated but it looks great
it's not a fun rabbit hole
Seriously, you're almost there. When the slider value changes, use that Unity event to call a method on an audio manager that changes the volume of the appropriate mixer . . .
ya, i have scripts that run while im dragging.. it changes the value to display the sliders and stuff but only gets saved if i press save..
back returns them to their original values.
(it saves to a json) so all i got to do is load up that data WHEN i get my mixers implemented
so far its just saving to the JSON.. I can view it, but theres no audio manipulation yet
so i actually have 2 systems at work.. one is realtime, and monitors the sliders (updating the values as i slide)
and the other system stores teh data when i click the save button.. and will revert back to the original values if u dont save
gosh, its so messy
love it when devs are shy about the state of their projects 🤣
i like showing off the pretty stuff..
My room can be in complete disarray and i'll be fine with it but please don't look at my code hahah
understandable hahaha
but i hide behind most of my code. b/c even tho i understand it, its always messy and theres better ways
when i show the actual backend stuff
also I was stalking your itch.io and just had to point out you left this guy on read for 288 days 
lol, wasnt important to him or he woulda bugged me about it 😄
🤣 🤣
plus i dont usually give out freebies for my projects to strangers
i worked hard on that.. (i would imagine) lol
especially not to people called Isaac_baguette
Yeah it doesnt look like an easy feat
i gotta get some more stuff on itch.. thanks for reminding me
ohhh! thats because it was all Rick and Morty stuff
thats what i'm here for lmao 🤣
didnt wanna get sued, for distributing it
Ahhh hahaah makes sense lmao, >inb4 adultswims lawsuit
should've called it the "Smif House, completely unrelated to the Smith House"
fun fact on that, the inside of the house (on the show) doesnt match the outside of the house
thats why i quit on that project
Save systems are awesome when they work. I like waiting to save until button press. It's easier than constantly saving when a value is updated . . .
its one of those impossible spaces.. id have to do some closed doors (swap the environment out) kinda deals
ya, i agree i only save when u press the button.. (this saves to json)
but if u just mess with the sliders and go back they revert to the default values..
i just needed teh realtime stuff so the slider values would update while u drag the handles around
all the runtime stuff
but this is all there is to the actual save
@rocky canyon looks like you need a custom editor . . .
i tend to try to stay away from those.. i get too involved
its probably my biggest time-sink
On some spongebob's pineapple type shi
LoL, this is about as much custom inspector as I do nowadays
🤣 probably my favorite (system) ive written
string TextField ftw
I'm trying to learn UI Toolkit. It's nice making custom editors and drawers, but I need to understand the code part
I'm trying to display the correct class based on the value of a field, but the class is either the base Stat or the derived Resource
I'm using SerializeReference for the first time, but I'm not sure if I create a new instance or specifically draw the correct property drawer . . .
got to do it all manually
i tried using that yesterday with a custom inspector type that.. that was supposed to show me a list of interfaces i was using
make your own UI for it, and isntance objects manually
but i couldnt get it to work correctly
I don't do crazy stuff either. I mainly just group fields or sliders and stuff together. I might create a tab for different fields to look at . . .
i was using it to repersent nodes in a behaviour graph for a while, but ended up dropping it since it was ultra fragile to refactors
and thats actually why i use the text field.. to print out the selected interfaces i have in my list
as i know no other way to expose it in the inspector
public List<ISelect> selected = new List<ISelect>();```
if(Physics.Raycast(ray,out hit,distanceOfRay))
{
focusedTransform = hit.transform; // not needed here (this is realtime raycast transform)
if(hit.collider.TryGetComponent(out ISelect selectable))
{
scrollLock = true; // enable the scrollLock flag
hold = true; // enable the hold flag
drag = true; // enable the drag flag
lastSelectable = selectable; // cache our selectable
storedTransform = hit.transform; // cache our selectable's transform
initialMousePosition = Input.mousePosition; // Store the initial mouse position when the drag starts
}
else
{
Instantiate(groundSelectPrefab,hit.point,Quaternion.identity);
Debug.Log("We clicked something unselectable");
lastSelectable = null;
}
}```
That sucks if refactoring made it unusable . . .
yeah ended up repersenting my nodes with SO's instead and just using a abstract type
I take it then; I need to create and add the StatDrawer (uxml created file) or the ResourceDrawer to the root based on the value of a different field . . .
them having guids for the types made them less fragile to stuff like renaming a type
Oh, I'd hate that. I rename mine all the time. I'm wishy-washy . . .
otherwise they worked fine, once i made UI and code for creating them
and i could clearly see in the yaml, they were stored in 1 blob at the end that included type information, then referenced elsewhere
lol, im also wishywashy, i abuse the F2 button
pretty sure if i bothered matt ellis rider would get support for refactoring them
Man, I keep forgetting to start using Rider. . .
Can yall point me in a direction to increase the visual aspects of my game?
no time like the present
not really a code question
Apologies
would it be better fr #💻┃unity-talk ?
No
probably #archived-shaders
sure, although you should be specific what you're asking
The question is vague as hell
Yeah I get that but it's cause I have no idea what to ask, thats kinda the problem 😭
I dont know if I need shaders, lighting, post processing, or a combination of all lmao
Figure out what you want to emulate and ask about that
General question, does OnBecameVisible / OnBecameInvisible cause GC Alloc?
Don't see why it would
If you're concerned about allocations, use the profiler
i'll try my best 🙏🏼
after profiling, it seems like the function is causing alloc, must be something in the function then
and don't cross-post
Quick question: I have an Attribute class with a StatType and [SerializeReference] Stat field. You're saying I'd have to assign the managedReferenceValue to the appropriate type and it'll draw its own custom property drawer?
by default SerializeReference draws nothing if the value is null
If you assign a value, it will draw the property
Wouldn't it create an instance of the type in the inspector?
Unless you assigned it a value, it's null
no
it's serialized by reference
null since its truely points to data elsewhere unlike serilziefield
you can have many things pointing to the exact same data with it
...when it's not buggin' out
yeah mentioned it breaks very easily, expecially to things like type name refactors
You definitely have to learn the additional attribute: MovedFromAttribute
and use global find and replace a bunch
yeah because it references regular types and not just components and so's
it has no guid to track for the types
It's annoying that there's no attribute for renaming the type, just the field or the namespace/assembly
Okay, thanks. I'll test and, hopefully, figure this out when I get on the computer—I never used SerializeReference . . .
That sounds scary . . .
I'm having some trouble, with checking whether or not the goblin is airborne by using raycast
For some reason they get stuck though.. I'm guessing maybe the ray is being cast under the map?
where is the pivot
I believe in the center? but I'm not quite sure, I'm quite new to Unity
you have to change it fom Center mode to Pivot
I'm sorry I'm having difficulties understanding 😅
ah okay
U want to see where the pivot point is?
yup.
so you're saying the Raycast is returning false then?
Yes correct
bool isAirborne = !Physics.Raycast(transform.position, Vector3.down, 1f);
if (isAirborne)
{
Animate(AnimationType.InAir);
}
Despite my character being on the floor the code inside the if statement is being triggered
My guess is that the pivot point is under the map? since the floor is just a plane
put the out parameter on the raycast and Debug.log what you're hitting or not hitting
Okidoki, one moment
😅
how did u write it
doesnt this indicate that its working then? there is no collider because you did not hit anything
Right but it's supposed to hit the floor
use debug.drawray to visualize your raycasts. might just be that your raycast is starting inside the floor thus not hitting it
i start my raycast a little higher up, then just raycast that distance further
Yeah thats the running theory
let me try one sec
cant even see the green gizmos in this shot 😆
hahaha sorry I thought the parametres on the right would be nough
green gizmos are barely visible
too thin?
should try printing the visual ray, but also I would try starting the character higher up in the beginning of the game
that might def be starting inside
Thats a really good point, but I'm doubtful whether it'll fix it
I could also just duplicate the floor
and put one underneath it
if it work it works type shi
its not a fix dude its meant for debugging
you could easily just test this by moving the goblin up and see if it works. takes 5 seconds
Ah my bad lol
Debug.DrawRay(transform.position, Vector3.down * 1, Color.red, 1);
if (hit.collider == null) return;
Debug.Log(hit.collider);```
my camera rotates when I press play again 😅
the log should not be in if statement
also, duplicating the floor is probably one of the most random "solutions" ive heard. Just move the goblin, or move the start of the ray up
lmao look i'm a hot glue gun fixing type programmer okay 🤣
I'll move the start of the ray up
hi idk why but i can drag my script in but it wont let me select the function inside the script
you need to drag in an instance of the script, not just the script from the assets folder
oh
https://unity.huh.how/unity-events/incorrect-assignment should be clear enough of an explanation
The matter has been effectively addressed and resolved with optimal efficiency, aligning seamlessly with our organizational objectives and fostering a paradigm of excellence.
Thanks 🙏🏼
i would hardly say with optimal efficiency, considering you guessed the issue (kinda) from the beginning but didnt test 😛
for some reason even though this image is above the button in the hierarchy its not showing above it
it's below in the hierarchy as far as UGUI is concerned. Also a question for #📲┃ui-ux
Only been working with unity for 4 days now 😅 but now I'll now for the future that raycasting is an option :))
my friend has a main menu where after he presses the button and goes to his main scene, the lighting in his scene is messed up
this is a #archived-lighting question
I'm a novice but dont coroutine's usually use IEnumerator?
I have the following code here online which sets a timer which works fine
time -= Time.deltaTime;
int minutes = Mathf.FloorToInt(time / 60);
int seconds = Mathf.FloorToInt(time - minutes * 60);
text.text = string.Format("{0:0}:{1:00}", minutes, seconds);
However, I'd like to include milliseconds, but I can't figure out how sting.Format works
why not just use TimeSpan?
its c# class
private TimeSpan timerDuration = TimeSpan.FromSeconds(5);
private TimeSpan currentTime;
private void Awake() => currentTime = timerDuration;
void Update()
{
if (currentTime.TotalSeconds > 0)
{
currentTime -= TimeSpan.FromSeconds(Time.deltaTime);
string timerText = string.Format($"{currentTime.Minutes:D2}:{currentTime.Seconds:D2}.{currentTime.Milliseconds:D3}");
Debug.Log("Time remaining: " + timerText);
}
else
{
Debug.Log("Timer has reached zero!");
}
}```
https://learn.microsoft.com/en-us/dotnet/api/system.timespan?view=net-8.0
I was able to get a little bit working actually
time -= Time.deltaTime;
TimeSpan t = TimeSpan.FromSeconds(time);
text.text = string.Format("{0:0}:{1:00}:{2:00}", t.Minutes, t.Seconds, t.Milliseconds);
but I still don't know how string.Format works and am just doing random things (like idk what D2 or D3 means)
also, milliseconds shows up in 3 digits, when I only want it to be formatted as 0:00:00
put D2 then 🙂
that didn't work either
well I wrote it like this, I don't know if I did it right
text.text = string.Format("{0:0}:{1:00}:{2:D2}", t.Minutes, t.Seconds, t.Milliseconds);
sorry just devide by 10
$"{t.Minutes:D2}:{t.Seconds:D2}.{t.Milliseconds/10:D2}");
there is also more methods here https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-timespan-format-strings
that works, thanks!
now the format's redundant
true 😅 late night oversight
how do I use screenpointtoray with a different cursor size. Like I want to increase the size of the raycast from the camera.
screenpointtoray has nothing to do with interacting with the scene, it returns a ray, you choose what to do with it.
Use a SphereCast, or multiple raycasts
well i want to cast what im clicking on just with a larger circle cast
then use the mentioned methods, rays are lines they dont have width just length
no i understand those methods
I dont understand how I can cast them without screentoworldpoint
There is nothing wrong with ScreenPointToRay
should i just do a sphere cast on my cursor with 100000000 depth (like this isnt making sense)
they have direction ray same as raycast
No? Just use a spherecast with the radius you care about
spherecast where?
down the ray you are getting?
oh do you mean the spot where screentoworld point hits?
Youre still using ScreenPointToRay
yeah thats what i mean
it returns a ray and you pass it to spherecast
okay ill try that thanks both
anyone know why this might be happening?
the zombie floats after colliding with my wallnut
well u never click the zombie.. but im guessing they're set up similar to the player.. does it have a rigidbody?
does the rigidbody also not have gravity?
yep they both dont have gravity
thats why it float away.
and Y position is not locked
ya just do that ☝️
how would i capture event when person clicks the dropdown button to expand dropdown? there is drop down onValueChanged but that is for when you click an option different from the previous one
Assuming you mean the unity drop-down "template", then it's not a single component. It has a button for the drop-down afaik. You can subscribe to it's on click event.
guys ik this is not the channel to ask this but can anyone tell me if there is an alternative to #⛰️┃terrain-3d cuz i never get help there
how can i go about rotating a 3d gameobject towards the mouse position. I have done this in 2d but cant seem to find a way to make it in 3d
rotate in 3d as in?
like while looking it rotates?
thank for response.. but i checked and when I clicked on the "Template" GO, it does not highlight the dropdown button area. The "Label" and "Arrow" part at least is in the click area of that button
The arrow probably has a button component.
like rotating the gameobject on the y axis
to "look at" the mouse position
in that case just get the getaxis raw of mouse x multiply that with sens
then use yrotation += mousex
then use transform.rotation = Quaternion.Euler(0,yRotation,0)
no, unfortunately not
alright let me try that
Then it's probably used as a target graphic by the actual button that is on a different component.
Or the button uses a different overlapping image.
what is "yrotation" here is it the mouse's y rotation or the gameobject's?
it is your mouse input
Hey all.
So in my unity project i want to spawn an object at a random position. The player must then click on that object to collect their reward.
My issue is now, i can get an object to randomly spawn but i cant get it to click.
I have made it a button but it still wont click.
How can i make this object clickable?
I have tried googling but they only showing me how to make an object spawn on mouse click. I dont want that. I want the object to spawn which i have done, then i want the player to click on that object which will then pop up a panel with the reward they have received.
And help would be greatly appreciated.
First decide/explain what kind of object is that? Is it part of the ui? Is it a physical object in the scene? Is it 2d? 3d?
Its a image of a turd.
I have a little pet that walks around and every few minutes he will drop a "turd". The player then has to click on that turd to clean it. Which is supposed to pop up a panel to give them one of 4 different rewards.
That doesn't answer any single one of my questions....
ok so i tried this but since mouseY is a vector3 i cant use it in a quaternion
i feel like that was said for comedic value, rather than actually trying to clarify
transform.rotation
lol im so dumb
It's fine if it was along an actual clarification, but there isn't one at all...
it was pretty sincere to me
I suppose its part of the ui as its an image.
Its a plain 2d image sprite that i used.
Not sure how to spawn a physical object
Image? Or Sprite?
What component renders it?
Because there's an Image component and a SpriteRenderer component.
heres the result its kinda weird
show me the code
Well i drew this 💩 in paint.
Then i added it to my assets.
Then there are 3 ways i can add it. I can drag that image i made into my hierarchy and it shows up on my screen, i then resize it and make it a prefab. My pet then poops it out every few minutes. But still cant click on it even if i add a button component.
I also tried making a image by creating UI -> image. But also cant click it when it spawns.
I tried making a button by UI -> button. But it also wont click when spawned
Im not sure whats going on.
How would i go about spawning an object with a button on it instead of a ui element?
is the 4th line mouseY a float?
make another float variable
public GameObject body;
float mouseX = Input.GetAxisRaw("Mouse X") * mouseSens;
float mouseY = Input.GetAxisRaw("Mouse Y");
mouseY += mouseX;
body.transform.rotation = Quaternion.Euler(0, mouseY, 0)
alright
ok
so instead of mouseY += mouseX i do rotation += mouseX
yes
You should start with doing it one way first and ask for help with your existing setup instead of restarting from zero and then asking here without any setup at all.
It is possible to make it work both with a ui Image component and a non ui SpriteRender component, so you need to decide which one suits you better.
sure
public Rigidbody rb;
public float moveSpeed = 10f;
Vector3 PlayerMovementInput;
public GameObject body;
private float rotation;
public float mouseSens;
void Update()
{
PlayerMovementInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical"));
float mouseX = Input.GetAxisRaw("Mouse X") * mouseSens;
float mouseY = Input.GetAxisRaw("Mouse Y");
rotation += mouseX;
body.transform.rotation = Quaternion.Euler(0, rotation, 0);
}
private void FixedUpdate()
{
Vector3 MoveVector = transform.TransformDirection(PlayerMovementInput) * moveSpeed;
rb.velocity = new Vector3(MoveVector.x, rb.velocity.y, MoveVector.z);
}
working on an isometric game
i think the approach is wrong we r rotating it with mouse input i think we need to make it so that it looks towards the mouse
let me see
public GameObject player;
void Update()
{
Vector3 mouse = Input.mousePosition;
Vector3 mouseWorld = Camera.main.ScreenToWorldPoint(new Vector3( mouse.x, mouse.y, player.transform.position.y));
Vector3 forward = mouseWorld - player.transform.position;
player.transform.rotation = Quaternion.LookRotation(forward, Vector3.up);
}
something like this
wait this might also have a problem
that should be fine
if you want to do it by look rotation
but this would be instant and not lerped
let me give it a try
should that matter as it would follow the delta pos of the mouse?
I need to have the zero vector as a default parameter and I want my function to be as uncluttered as possible to do this
this does NOT work:
public void SetupClone(Transform _newTransform, float _cloneDuration, float _alphaFadeDuration, bool _canAttack, Vector3 _offset = Vector3.zero)
{...}
so close
well, I guess it comes down to how the character should behave if quickly changing rotation from say angle 0 to 180
that last one, the offset, is a new update to this function and if we don't want an offset, I'd like it to just be the zero vector
what specifically does not work?
if there's a way to do this without an "if" statement in the function, I'd like to know
also im trying to rotate a children of the player gameobject
I get this error:
Error CS1736 Default parameter value for '_offset' must be a compile-time constant Assembly-CSharp D:\Unity\RPG Alexdev Course\Assets\Scripts\Skills\Controllers\Clone_Skill_Controller.cs 36 Active
i think its worse as u cant look forward now
vec3.zero is not compile time constant
Vector3's have no compile time constants
it is static readonly (or something similar to this) iirc
Yes. The only option is default.
Shirly, there must be a workaround 🤔
Either use default, or just make an overload
float CameraDistance = Camera.main.transform.position.y - transform.position.y;
Vector3 WorldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
WorldPoint.z = CameraDistance;
float AngleRad = Mathf.Atan2(WorldPoint.y - transform.position.y, WorldPoint.x - transform.position.x);
float AngleDeg = (180 / Mathf.PI) * AngleRad;
Body.rotation = AngleDeg;
i found this online try this one
what will 'default' do?
also, use a standard naming convention for parameter names... not whatever this is
that's interesting. Maybe screentoworldpoint isn't accurate with isometric view
alrigh
you mean _offset?
You should really virtually cast against a Plane instead of doing this
all of this guy's parameters are named like that in the tutorial and it's actually almost 40 hours long 👀
I'm in too deep
Who on earth is it? Because in no world do C# method parameters start with underscores
well i dont think that worked
how should method parameters start
they are camelCase. The standards are pinned to #archived-code-general
default will be the default value, i remember having this annoyance with rotation
which is worse cause iirc default rotation is an invalid Quaternion
i will try different solutions and if they dont work i will your suggestion
var mousePos = Input.mousePosition;
var wantedPos = Camera.main.ScreenToWorldPoint(new Vector3(0, mousePos.y, 0));
Body.LookAt(wantedPos);
if this work then okk else i m not really sure
so I believe that his intention (and this does make sense to me) is to be able to use meaningful names as parameters and as arguments that are defined in the classes or methods that call those functions.
honestly consider getting this to work this way instead of casting because mapping x/y should work to map out your forward direction
Of course it is, they're just at a constant distance from the camera, which is at an angle, and that position doesn't make sense to sample against a flat plane
so SetupRunSpeed(float _runSpeed){...} could take on float runSpeed as an argument
That's just backwards though
there is no case where you need _ in the parameter, even if you have a duplicate name.
float something = 4;
void Test(float something)
{
this.something = something;
}
this exists
yea then screen to world wont work
when I do new Vector3(), is that the zero vector by default?
because that is working as a default parameter
numerical value types are initialized as 0
so yes then?
unfortunately, that didn't work but nonetheless thank you for your help
(see Using a Plane if that was unclear)
and provide a plane at head-height aligned with the ground
Hii, i have a problem here. so i have a variable or attributes money that was a float and started from 0. and i have a funct when clicked a button it will be +0.001 how can i make it? i already make like this but its wrong public void Clicked()
{
float money = ++0.001;
}
is it money += 0.0001; or what
the float has to exist outside the method scope, otherwise this wont do anything (wont even compile in this case). You should look at some c# basics first
your float should also end with f
ooh alright i forgot the f my bad
this works perfectly, thank you
vertx suggested it 😅
ok so i found a really good solution that works to my problem found this on the internet
Vector3 mouse = Input.mousePosition;
Ray castPoint = Camera.main.ScreenPointToRay(mouse);
RaycastHit hit;
if(Physics.Raycast(castPoint,out hit, Mathf.Infinity, ~playerLayer))
{
Vector3 playerHeight = new Vector3(hit.point.x, this.transform.position.y, hit.point.z);
Vector3 hitPoint = new Vector3(hit.point.x, hit.point.y, hit.point.z);
float length = Vector3.Distance(playerHeight,hitPoint);
var deg = 30;
var rad = deg * Mathf.Deg2Rad;
float hypote = length / (Mathf.Sin(rad));
float distanceFromCam = hit.distance;
if(this.transform.position.y > hit.point.y)
{
requiredHitPoint = castPoint.GetPoint(distanceFromCam - hypote);
}else if (this.transform.position.y < hit.point.y)
{
requiredHitPoint = castPoint.GetPoint(distanceFromCam + hypote);
}
else
{
requiredHitPoint = castPoint.GetPoint(distanceFromCam);
}
}
thing.position = hitPoint;
which just puts a gameObject to the mouse position by using raycast then i made it so my player/the player's children looks towards that gameObject like this,
Vector3 thingPos = new Vector3(thing.position.x,body.position.y,thing.position.z);
body.LookAt(thingPos);
what on earth was wrong with my simple solution
im sorry bro i was trying this out 😭
thanks tho
aight im dipping from here
thats an interesting way to declare hitPoint as well
Insane to cast against geometry only to do trig against a virtual plane vs just using the plane
Only one benefit/drawback, if you weren't hovering a collider, it doesn't look in that direction
why is there no mesh being rendered when i run this code
// mesh variables.
Mesh mesh;
Vector3[] RoomVertices;
int[] RoomTriangles;
// room information.
Vector3 FirstPoint, SecondPoint;
// this function takes the two defining points and defines the vertices and triangles for the room mesh.
void CreateRoomMesh( //Vector3 Point1, Vector3 Point2
)
{
RoomVertices = new Vector3[]
{
// i will replace the 0s with point1 and the 1s with point2 later.
// bottom vertices
new Vector3 ( 0 , 0 , 0 ),
new Vector3 ( 1 , 0 , 0 ),
new Vector3 ( 0 , 1 , 0 ),
new Vector3 ( 1 , 1 , 0 ),
// top vertices
new Vector3 ( 0 , 0 , 1 ),
new Vector3 ( 1 , 0 , 1 ),
new Vector3 ( 0 , 1 , 1 ),
new Vector3 ( 1 , 1 , 1 ),
};
RoomTriangles = new int[]
{
// floor
1, 3, 2, 2, 3, 4,
// ceilling
5, 6, 7, 7, 6, 8,
// east (positive X) wall
2, 4, 8, 8, 6, 2,
// north (positive Y) wall
4, 3, 7, 7, 8, 4,
// west (negitive X) wall
3, 1, 5, 5, 7, 3,
// south (negitive Y) wall
1, 2, 6, 6, 5, 1
};
Debug.Log("mesh vertices are cooked");
}
void UpdateMesh()
{
mesh.Clear();
mesh.vertices = RoomVertices;
mesh.triangles = RoomTriangles;
Debug.Log("it should be updated now");
}
void Start()
{
mesh = new Mesh();
GetComponent<MeshFilter>().mesh = mesh;
CreateRoomMesh();
UpdateMesh();
}
when i inspect the mesh thats inside the mesh filter this is what it shows me
Seems like there's no triangles. I can assume that means that that didn't work, where I presume that there's an error/warning in the console, and then I look at your triangles array and note that it's not 0 indexed and your indices are out of range for 8 vertices.
ok so what do you mean by indexing 0 in the indeces
it did error
indices start at 0, not 1
😭
so this is uselss now
i have to subtract 1 from each of them
yes
nooooooo...
write a script that deducts it all for you
Which you can do with IDE trickery with a good plugin
bro thats gonna take 2 hours to mke
If you use
I recommend String Manipulation
as much as I hate working with microsoft excel, it's good at dealing with problems like this ahaha
bro procedural generation is already brain melting enough i dont think i have any brain juice left to learn how to make a script that deducts 1 from a list of numbers
Wouldn't it just be...
cs for(int i = 0; i < RoomTriangles.Length; ++i) RoomTriangles[i] -= 1;
parsers are fun
could probably just throw it into chatgpt and it'll spew it out for ya
RoomTriangles = new int[]
{
// floor
0, 2, 1, 1, 2, 3,
// ceilling
4, 5, 6, 6, 5, 7,
// east (positive X) wall
1, 3, 7, 7, 5, 1,
// north (positive Y) wall
3, 2, 6, 6, 7, 3,
// west (negitive X) wall
2, 0, 4, 4, 6, 2,
// south (negitive Y) wall
0, 1, 5, 5, 4, 0
};
wait what
JetBrains Rider
oh well too late i already did it manually
pay2win
that costs $?
why is dollar sign banned
Probably because you just posted a single character, which is a bad way of communicating
oh
You can type $ just fine
Subscription fee https://www.jetbrains.com/rider/buy/#personal
CUBE CUBE CUBE
Yes, it costs money, students can get it for free, and the early access program is free while it's running (it just started again)
💀
i am a happy boi now
im studying a very complex code, what is the ref here :
function(ref .... , ref,,,,)
Passes the variable by reference
ref is used to pass a value type parameter by reference instead of by value
im looking at a chaotic system, not function, and that system is hooked onto a custom library
in fact i dont even know where to start
If it has parenthesis after indentifier, it's a function/method. Or a constructor.
Or a delegate(but that's basically a method/function)
to be very simple, im in charge of fixing one of the function in this chaotic system
it is a function to draw icons of a grid
by nature, it is a normal void function
generally do you want to put the true condition in an if else statement first?
Depends
in this case the true option MUST come first
why is that?
because that is how the statement is evaluated
I assume what they're trying to ask is wether the should do it as in their code or !IsCasting ?...
condition ? if true : if false
How do I check whether a collision occurs right at the start?
then I would say which is more readable or more likely
Hey Steve how are you? We talked yesterday you remember? I understood what the problem is but i couldn't solve it anyway, can you help me? It drives me crazy. It's a very crucial mechanic of the game and i need to finish the project in 2 days
A physics query. But ideally, you shouldn't get into a situation where you need to check that.
okay
this is the code i modified https://pastecode.io/s/r4fwn8fh
Did you not implement this ? #💻┃code-beginner message
Ah, yes you did, you added canAttack
but you didn't do what I said
it doesn't work. I thought i need to find a way to turn canAttack to true when the RandomlyChooseAttack(); but tried and it didn't work either. I need to turn canAttack false right when attack starts
how to optimize, without changing the library function
cuz im strictly warned not to change one single bit of the library
what are the ref values after the method is called ?
get rid of string, but you cant do that
the left is to use own parser without any split() or regex \d+ since you already know the format
there is just not enough information there but maybe something like
List<Vector2Int> vectors
...
vectors.Add(new Vector2Int(int.Parse(coord[0,0]),int.Parse(coord[0,1])));
oh did i misunderstand the format?
[["123","456"]] or [["{{123,456}}"]]
then you just access the color by corrdinate
the right one and the upper graph has additional functions
so its using a model class to contain the info
instead of string[,]
bruh its far comlicated than i thought actually
i think just keep it this way for now
thx guys
Do enum count as "class"? I can't create a class in Unity as "class already exists"
I have enum called that
enum is a Type so it cannot be the same as a class name
alright thx
hello, I followed a tutorial to make my character jump in 2D, then to make him jump only once. Even after following the tutorial, my character continues to jump endlessly, can you help me?
most likely your OverlapArea is detecting your player's collider because you aren't using a LayerMask
also !code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
What is a layerMask ?
such a google question
Anyone know if you can anchor 2 views together?
E.g.
<A> END anchored to <B> start. With an offset of 10 for spacing.
So if I move <A> up or down, <B> mirrors the layout changes to A + the 10 spacing.
I've seen arrows in videos about this, but the video doesn't mention anchoring to other views. Only anchoring to corners and then everything else is offset.
Is there any way (Ideally in GUI) to anchor views together?
Hey guys, weird question but maybe you have the answer.
I'm following some tutorials on aiming, I have a crosshair with a sphere at the target point (where it's going to land)
I'm using a raycast for that, so when I'm rotating my character too fast, the sphere does not follow perfectly and takes some time to go there.
Is there a solution to fix this issue?
https://www.youtube.com/watch?v=FbM4CkqtOuA&t=1365s here is the reference video, 17min30ish
💬 How to make a Third Person Shooter Controller in Unity!
✅ Get the Project Files https://unitycodemonkey.com/video.php?v=FbM4CkqtOuA
🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Games https://unitycodemonkey.com/gamebundle
00:00 Third Person Sho...
this is a code related channel
yes you can
Can someone help me to fix this? i have try anything but is still error
Did you test it out or search for a link? An answer should've popped on the top three results . . .
googling something should be the first thing you do when you have a question like that.
figured it out
seems like your navmeshagent is not actually placed on a navmesh. of course that isn't a code question
Is your navmesh agent active? Is it on a navmesh?
thats the thing, i dont know how to active the agent. can you explain?
active meaning not disabled in the scene
ah i see, so what should i do
well you need to ensure that your navmeshagent is on the navmesh at the time you call the SetDestination method
how to do that?
place it on the navmesh . . .
wait i will try
thanks
Did you happen to follow a tutorial? There are a bunch that will explain the process more thoroughly . . .
yes i do, but it still
If it's working on their video, I would rewatch it. It seems you missed a step . . .
... Not neccesairly, a lot of videos about navmesh are outdated and a lot has been changed in the newest versions comparing to some old tutorials ...
well we also know absolutely nothing about their setup (except that they are using an older version that tutorials will likely cover) since they didn't deem it worthy enough to share so we can really only speculate
yup
why isnt this working?
could not cast or convert string to Level
!code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Because a Level and a string are not the same type . . .
JsonUtility.FromJson<SaveObject>(saveString);
instead of deserialize?
Interesting, I'd have to try a few of them—when i get home—see if they still work . . .
JsonUtility cannot deserialize a Dictionary
well it works fine for me
but i have my own serialized dictionary
so maybe the normal Dictionary doesnt work
yeah that's why it works for you
SaveManager.LoadClass<GenericDictionary<ChuckwagonType, int>>(GameSaveManager.Instance.currentSaveSlot.ToString(), SaveType.CHUCKWAGON_LEVEL);
public static T LoadClass<T>(string ID, SaveType saveType) where T : class
{
string keyString = GetSaveName(ID, saveType);
if (!HasKey(keyString)) return default(T);
string loadedJson = (string)savedFormatedData[keyString];
return JsonUtility.FromJson<T>(loadedJson);
}
You need to split the values and keys of the dictionary into two lists and save those lists. When deserializing, create the dictionary using both lists . . .
interesting that's good to know
Yeah, that'll do it. A custom one is different from the default dictionary . . .
or make your own custom, serializable dictioanry
you can edit it in the inspector + save it/load it via json
thats a real bitch
I agree, but that's out of scope for them (at the moment) . . .
thanks guys
i thought adding the [serializable] thing would fix that issue but ig not
nope
is it because "level" is a SO?
scriptable objects are serialized, actually everything that shows up in the unity inspector is serialized
except you aren't even using jsonutility, you're using json.net which can serialize dictionaries
im using newtsonsoft.json
oh right
so what the hell
its weird cus
its serialising it fine
but it cant deserialise it
the issue is likely how you are serializing it. but why are you serializing a ScriptableObject in the first place?
im doing like a save map, which maps a level to the players level data like completion time or whatever
how is that bullshit?
im talking about built-in SO not some assets lol
scriptableobject is meant to be a custom asset type, its just kinda over complicating things to use for runtime saves
when you can simple serilize out any data structure without the overhead and complication
if it will work with saving/loading it via json then im buying it right now lol
what is says, saves and loads So data at runtime, makes SO's mutable
what is a copy constructor?
yep
a constructor takes takes its own type as a arg, and coppies the data into the new instance
Everything . . .
that's kinda too complex to save/load SO via json, i've been trying to do that for quite a lot of time and just gave up and did a workaround
@stuck palm
^ that except you'd want it to take the SO rather than its own type
yes
and have a different Dictionary<LevelEnum, Level>
so you load the Dictionary<LevelEnum, LevelStats> with JSON, then get proper Level frmo the 2nd dictionary
question if this is for save data why do you want the SO in the first place? is this for just refernecing it, or is this for defaults?
he wants to load the saved level data
@stuck palm i made this workaround for exactly same problem you have right now
and it works perfectly
level just works well in game to easily make new level data where i can just change values on the fly
where would these dictionaries be stored?
i mean like on what class
idk up to you, in some kind of SavedLevelManager
thank you, it looks good and i know what you want me to do but im just confused as to what the enum would look like
make a enum LevelEnum, fill it with entries like LEVEL_1, LEVEL_2
make a Dictionary<LevelEnum, LevelStats> - this will be the one you save/load with JSON
yeah i think i got it
and make a Dictionary<LevelEnum, Level> where you have all the levels assigned
and then you can work with it
so then you can like link the Dictionary<LevelEnum, Level> to the Dictionary<LevelEnum, LevelStats>?
well you access the data in both using the same key
if you really wanted to link them could just fake it with a Getter
So like LevelStats could have a getter that does a lookup into the dict with levels
yea
then i can make the final dictionary using those two
not needed really
why?
i mean you could after you load the saved json
if it's easier for you
yeah after the json is loaded
yea sure then you can make <Level, LevelStats>
its needed for some logic i have going on
and work with it
awesome
i still encourage you a lot
thanks i have an idea in my head on what to do now
to make a serializable dictionary
so you can fill dictionary keys/values
in the inspector
it's game changer
i dont understand, cus the dictionary is being serialised into a json
is this like a paid asset
no i made this myself
i can probably find a serializable dictionary online
no its easy
might as well do it now then
use the GenericDictionary from github
and all you need to do then is to just replace
all Dictionary<> to GenericDictionary<>
it's honestly a game changer, saving tons of time
could i have a link please? i cant find ti on google unless this is it
for example this is a `GenericDictionary<BalistaEnum, GenericDictionary<int, bool>>
so i have a dict inside a dict
so for example i can check if FIRE balista level 1 is unlocked
this way
would i still have to do the enum method by doing this?
okay
you cannot save it via json
do u have a link for the generic dictionary? i cant find it
copy the Editor and Scripts folder
okay, thanks
I’m late to the party, but why a generic dictionary and not just a dictionary?
and i only have to make Dictionary into GenericDictionary? it all still works the same/
so you can modify it in the inspecotr
this one looks a little less clean than yours lol
but if it works hey
yes
im happy either wa
yea because i also have Odin Inspector
which kinda changes the look of it
the default GenericDictioanry looks kinda different
but does the job still
try get to use it a lot, you can make so many great things with it
what, odin?
okay 😄 thanks working with it now
serialisable dictionary thing is gonna make the enum method a lot easier
makes it a lot easier filling the dictionaries in the inspector i was dreading writing it manually, thanks 😸
no worries, this will be your best friend very soon when you explore what you can do with it 😄
Where do I put the Time.deltaTime in my bullet shoot code? My bullets shoot slower when my character moved than when my character is still.
(Please answer directly, I have a mental disability and struggle with non-direct instructions)
https://hatebin.com/qpetiqjwrc
I'm still testing it, which is why there's only a code for "Level 0"
The code looks like it just instantiates the bullets, this code isn’t responsible for the bullets movement?
Oh thank you, let me post the other one. For some reason the movement is in a separate script...
why are you calculating frames?
How do I do that? I'm guessing I have to change the frameNormal++; to something else? I tried changing it to frameNormal += Time.deltaTime; but it didn't seem to work. It spawned no bullets.
why are you calculating the frames anyway?
!code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
To make it so the player only shoots once every 16 frames. Because a level up should half it to 8, and another level up should shorten it to 4.
wouldn't it be easier if the player can shoot every X seconds for exmaple
instead making it frame rate dependand
what is palyer A runs 60 frames per second
and player B runs 120 frames per second?
palyer B shoots more bullets in 1 second than player A
doubt it is intended behaviour
public int fireRate=100;//100 rounds per second
public float coolDown=1f/fireRate;//around 0.01s per shoot
public float idk_how_to_name_it=0;
idk_how_to_name_it-=dt;//eg if dt=0.03s, you should shoot three bullets
while(idk_how_to_name_it>=0){//note that you need a while loop since the fireRate is larger than fps=60
shoot();
idk_how_to_name_it+=coolDown;
}
i dont understand why im getting this error if im nullchecking? the error is on the highlighted line
Hm, thanks for telling me!
because the key you are checking
is not added to the dictionary
how do i check if a key is present in a dictionary?
i thought thats what i was checking
.Contains()
What is dt?
wouldnt it be contains key?
yea sorry
Also thanks!
deltaTime
if(dict.ContainsKey(key))
{
}
have to not handle stuff with frames at all, would decide how long you want to wait for the next shot, then keep a elpasedTime variable you add deltaTime to each update, and when it exceeds your wanted wait, you fire and reset elpasedTime to 0
how do i delete a file from the editor? i've got a save file somewhere and idk where it is and its messing with my code since i changed the values
dictionary has a method called trygetvalue
btw the indexer allows you to set the value even no such key
it's not in the editor
depends where you saved it
turns out old me made a debug message for the save location so i found it and deleted it
You should base it off of time not frames . . .
Real quick question, I keep switching them in my head, in C#, is it if (... and ...) or if (... && ...) for an if that needs both to be true?
&&
Thank you!

Is it safe to have nested foreach over the same IEnumerator IEnumerable?
You can only foreach an IEnumerable, and yes, it's safe to have nested foreaches of the same IEnumerable
Thanks 🙂
An IEnumerable is something that can give you an IEnumerator!
public void MapData(Level level, LevelStats ls)
{
if (loadedSave.savedLevelData.ContainsKey(enumLvlDict[level]))
{
loadedSave.savedLevelData.Add(enumLvlDict[level], ls);
}
else
{
loadedSave.savedLevelData[enumLvlDict[level]] = ls;
}
}
how do i fix this? something is already in this
well you cant add the same key
to a dictionary
What do you want to happen? Do you want the data to be overwritten? Do you expect this to be happening?
if it contains a key, you cant add the same key again
i wanted to overwrite the data
loadedSave.savedLevelData[enumLvlDict[level]] = ls; just this is enough
then use the myDict[key] = value; syntax
.Add specifically will throw an exception for a duplicate
The indexer does not, it overwrites.
cant belive that works by itself
If I have mutiple classes with the Update() method which classes code runs first? Is there a way to find out?
you can only specify order
https://docs.unity3d.com/Manual/class-MonoManager.html
Assume it runs in a random order unless you have specifically specified it.
Aight thanks :d
It can even change from platform to platform
its in the order they are loaded, which is arbitrary
@rare basin finally got the save file working thanks to your system 😄
yay
How could I make a little beep play when i hover over a button/select a button? I feel like it would be tedious to give every button a script to play a noise when hovered or selected
put the buttons in an array and use AddListener to tie a method to each button nvm that wont work for hover/select
I could just make a script actually, I don't have too many buttons in my game
I'm trying to reference a script to reuse variables but it won't allow me to drag the script into the inspector to give that script access. Hopefully I explained that properly.
hey this might not fit in here but i downloaded unity hub but when i try to open it it shows my mouse that its loading but then it just doesnt open up
Did you end the task and try again?
where do i end the task?
Task manager and search to see if Unity Hub is running already.
You might need to uninstall unity hub and reinstall
Or right click and try to run it as administrator
i tried that too
This might be a dumb question but did you restart your pc?
Wouldn't hurt to try it
Are you dragging the actual script file in the slot? You need to drag an object that has that script component
Look at the Hub log files.
!logs
alr
There is probably an error at the end of the log file.
how do i look at em?
I forget the exact name of the log file -- let me go look..
yh
If you paste this into the Run dialog, an Explorer window will open in the right directory
%UserProfile%\AppData\Roaming\UnityHub\logs
what now?
open the log file and look towards the end of it
that's generally where an error will be
Thank you I appreciate it.
literally the word "error" appearing in the logs
also, this isn't actually a code problem, so you should ask about this in #💻┃unity-talk
Then you wait
i didnt find anything??????????
no errors
hi guys i have a question im vreating a game 2d roguelike and i want to spawn anemies on the map anyone can help me ?
i have this map
how generate random map everytime i want
How did you generate that one?
I need urgent help.... In all my unity scenes most of the things turned pink(magenta) idk why and I also tried to convert materials to urp but it's also not working
here
Not code related at all, ask in #💻┃unity-talk next time, but your materials don't work with your render pipeline.
Then how it previously worked????? And then how it can be solved???
thats why you should sepaarate your UI
So then call that function to generate a random map everytime you want?
yes
So problem solved? #💻┃code-beginner message
for example make a ButtonElement prefab, which contains well - a button, and when you want to some kind of scripts to that button you only need to add it to the prefab @stuck palm
but the question is how can i place items and enemies in the map?
same with Text components, imagine you have 1000 text elements in your game and suddenly you want to change a font, you can do it with just replacing the font in a TextElement prefab instead of going to each element
How should I know? URP materials only work with URP. It was either not in a URP project, or it was not URP materials. No idea what you did.
Just make sure that your materials match your render pipeline.
i guess that could work yeah
how would u check if a button has been highlighted?
or selected
I used urp materials only
You need to first decide what your rules will be for placing the enemies on the map. Obviously it can't just be completely random, that wouldn't make sense for gameplay.
IPointerHandler interface
public void OnPointerEnter(PointerEventData eventData)
{
//play UI button hover so, switch graphics to "selected" or "highlighted" etc
}
you also have OnPointerExit so you can switch back the graphics
is that directly on the buitton itself or on an object with the button on it? if that makes ense
okay but any advice on how to do it like a course or something im making this project and im super late i need something
with an object that has Button component on it
There is honestly not a lot we/I can do here. Just make sure they match, or give an error message why it doesn't work.
This is still not a code problem. Please ask about it in #💻┃unity-talk .
I'm not going to search courses up for you on game design, no. If you're just wanting anything, then go the random route. Pick a random tile and place an enemy there.
Ok... Posted there
and if i pay you?
You can't afford me
that would be an extremely expensive way to use google
how much ?
But if you're interested in hiring someone. You can post on !collab
We do not accept job or collab posts on discord.
Please use the forums:
• Commercial Job Seeking
• Commercial Job Offering
• Non Commercial Collaboration
i think you should just try the most basic thing that works
owned
!collab
We do not accept job or collab posts on discord.
Please use the forums:
• Commercial Job Seeking
• Commercial Job Offering
• Non Commercial Collaboration
i think you need to do your homework
200$/hour and you can have me for 8h per day
you are a studdent?
i need the best
for 200$ i will be average, for 500$/hour i will be the best
@timid hinge Again, go to the forums to post for jobs. This isn't the place.
this is borderline spam
Also I suggest your change your trolling pronouns before you get kicked from this server as well.
sigh
They always have to show it off. Like those poison dart frogs that use the brightest most conspicuous colors
Why do my hands shake a lot? I use IK and change the weight. Code https://gdl.space/anageweleb.cs.
Is there any other way to change 0 to 1 smoothly?
you are Lerping wrong
this is not how you lerp
last parameter in Lerp is interpolationPoint, between min and max value
timeElapsed / lerpDuration
not changeSpeed * Time.deltaTime
I'll try it.
What's the website so i can send code?
!code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Thank you
note that this, alone, probably isn't causing the crazy vibrations
it's just going to make the speed of change framerate-dependent
Hey, is there a better way to have multiple animation curves in a script? I want to call different kind of curves for specific use cases. ATM i have a serializefield for every single curve. I was searching for something like a curvelist (if this is even a thing)
i need 10-20 curves and it makes the component and code really ugly
in a serializable dictionary
Dictionary<ColorEnum, AnimationCurve>
make an array or List
You have three separate two-bone IK constraints.
then you can access each curve by its color
They're probably just fighting each other
You should be changing where a single two-bone IK constraint is trying to go
thats sounds exactly like what i have been looking for thanl you
it is divided 50 by 50 and so on until 1 becomes 100 and the second 0
note that you need an addon to have serializable dictionaries
you can also just make a list of structs that hold an enum value and an animation curve
then build a dictionary out of that when the game starts
@echo matrix
public GenericDictionary<ColorEnum, AnimationCurve> animationCurves;
I see what the weights are doing. But you still have three different IK constraints here
then animationCurves[GREEN] gives you the curve assigned to green key etc
They're all going to be fighting over where the arm goes
What does Enum mean?

ok
and it should not mix the 3rd weight because only 2 will be active and then only 1
basically a fancy way of having "named numbers"
so you can interprete that enums are just Dictionary<string,int> in someway?
thinking process shortcut ofc
thx
https://hatebin.com/quvgsnjlhn
Anyone knows why the slime flies away? It seems like my Coroutine is not ending but i dont understand why. See video and attached code
They cannot interfere with each other because they will mix
Sort of??
More like:
const int Sunday = 0;
const int Monday = 1;
const int Tuesday = 2;
const int Wednesday = 3;
// etc...```
would be:
```cs
enum Day {
Sunday,
Monday,
Tuesday,
Wednesday,
...
}```
yea 😄
i mean, it looks like they're interfering with each other quite a bit in your video..
how did you do that? My version does not know generic dictioneries
GenericDictionary is a serializable dictioanry that shows in the inspector
not built-in in Unity
what do i need to get for it?
cuz like Sunday(key) = 0 (value)
make your own serializable dictionary
there should be some free on assetstore aswell
anyone?
show the inspector of the Knockback component
on the slime
also what is your timeScale?
also you don't need the enemy != null check again, since you aer already checking that
that's not the Knockback component
sorry here
and what is your timeScale?
timescale? O.o
nope
why are my buttons not working when i hover over them with the mouse? only works with the up and down arrows on thge keyboard. the sliders work fine tho for some rason
raycast target enabled on images on them?
noting else on top of that UI that could block it?
raycast target is enabled, and nothing else is on top
i have my update as FixedUpdate @rare basin maybe that is something thats causing it?
anything that is rendered on top doesnt have a raycaster on it so it cant block it
can you try disabling everything in the hierarchy below those buttons?
just to be sure
the only things that are below are the DDOLs
disable it aswell
the UI Canvas
also, if you in runtime make a new button on that object
nothing happens
is it interactable?
i dont understand cus the sliders work fine
so nothing is blocking them
its just the buttons
i'll try one sec
it does work yes
yup
something wrong with the button setup
show the hierarchy of that button
and that button component
you probably disabled the image component
so there is nothing that can "catch" the raycast
the new button is highlighted, here is an example of one of the broken ones
i havent disabled the image
and these buttons are basically exactly the same on the home screen and t hey work fine
i guess just make new buttons then, hard to say what broke
so idk whats up with that