#💻┃code-beginner
1 messages · Page 273 of 1
Okay, thanks a lot
Why does an animation event gets triggered, when the program starts?
It will trigger the moment an animator plays through an animation that contains an event
even if the animation has a very low weight
(not sure about when the weight is literally zero)
What do you mean with weight
How can I prevent it?
Is there a way to distinguish one character from another codewise without using tags?
if you have a blend tree, multiple animations can be playing simultaneously
sure -- at the most basic level, you can just check for reference equality
my idea is if(gameobject is "an specific character" and boost.doubleshoot) then code
if (somebody == another) {
// both variables refer to the same object
}
why not just give the Boosts object to the character?
then the character can decide how to change itself based on that data
i'll need to see the animator controller
the graph view of all the animator states
Oh yeah, it does have it but how can I distinguish that depending on the character has one boost or another?
including whichever state has an animation in it that causes an event
this is everythin
You don't need to. You just give the character the Boosts object.
If you need to know if a character has a certain boost, just look at its Boosts object.
you can make it a public field on the character class
okay, so the default state of the animator is "Object Throw to place"
With boost object you mean the script itself?
This animation plays when it gets triggered threw a script
boost is a variable that holds a reference to an instance of Boosts
Okay, but the default state of the animator is "Object Throw to place"
So that's the state the animator is going to start out in
If you don't want any animation to play at all at the start, create a new state that has no clip in it
then right click it and set it as the default state.
And what do I do with that reference exactly?
well, presumably, you're going to do something like this
Perfekt thx
public class CharacterDefinition : ScriptableObject {
public string charName;
public Sprite sprite;
public Boosts boosts;
}
you set up the boost data in the inspector
just like you've assigned a sprite and set the name
then, you'll have...
public class Character : MonoBehaviour {
public CharacterDefinition definition;
}
You can just pass the entire CharacterDefinition object to your character.
Is it better to make base classes or static classes for cross script communication?
"base classes" are an inheritance thing; they don't influence how different objects can communicate
check this out.
now, in the update method of Character, you might do this
Well what I meant by communication is just like getting stuff from the main script
void Update() {
health += definition.boosts.healthRegen * Time.deltaTime;
}
and what is a "main script"?
Just like the manager
For example enemy script and I wanna make multiple different enemies
But with this all characters would have Health Regen?
Sure.
But most of them would have a healthRegen value of zero.
So that line would do nothing.
Each enemy will have an instance of the Enemy component attached to it.
If all of them need to talk to an EnemyManager (maybe something that keeps track of how many enemies have been defeated), then there are a couple of options.
you could give them a reference to the EnemyManager when you spawn them
or you could make EnemyManager a singleton that you access through a static field
So that parameter is modified in the scriptable Object?
Yes -- CharacterDefinition has a Boosts field, and Boosts has a healthRegen field
you'll see "Boosts" in the inspector for CharacterDefinition assets.
So basically your saying just use GetComponent or make Enemy manager a static script?
No, I'm not saying to use GetComponent. That wouldn't help each individual enemy find the enemy manager.
See the first link I just sent
it explains how you tell newly-spawned objects about things in the scene
Well I’ve been doing this lmao because my enemy manager is in a game controller object
Currently anyway
But I’ll check the links
It does not matter where the enemy manager is.
Ty for help
yes but the thing is if I want that when a slider reaches maxvalue the player is allowed to use the boost (and I have that one character that has a double shot boost) then in my shooting script how could I make sure if it has reached it and, in the case I did (if (_value = _maxvalue) but I only wanted ONE character of the roster to have that hability how can I check that
You can just give a reference to the newly spawned enemy.
It is difficult to explain sorry
I was tryna automate it more
oh, so these are more like activated abilities than passive bonuses
still, it's pretty straightforward
So I wouldn’t need to click and drag every time I make a new enemy
each character should have a boost meter that doesn't really care what kind of special ability the character has
it's just a float
okay, I have that
Ability systems are a very common thing people ask about, and they can be tricky.
The simplest option would be to just make an enum for the boost ability (without using the "flags" approach -- just a normal enum)
when you hit the boost button, you use a switch to pick which code to run
switch(definition.boost) {
case Boost.HomingAttack:
// turn on homing attacks
break;
case Boost.Speed:
// double the player's speed
break;
}
If you need to be able to store some configuration data, I'd just stick it into a class like this.
It will have lots of pointless data (if you have the Speed boost, your config will still have data for the Damage boost and the Health boost)
but that's not really a problem
so there should only be one bool?
boostActivated?
And how can I regulate the access to the boost depending on the character my player is
If all characters gain boost in the same way, but just have different boost meter sizes, that can be a float on CharacterDefinition
Actually, you might just make each kind of boost a coroutine.
That way, they can manage their own data
IEnumerator HomingAttackBoost() {
homingAttacks = true;
yield return new WaitForSeconds(10f);
homingAttacks = false;
}
I have it configured like that
e.g.
the thing is
For example, one of my characters has a boost that allows to shoot a bullet that follows the target
and all of my characters have a shooting component
that does not affect the problem
shooting components are not static
they dont share datas
what do you mean? sorry Im VERY lost
ok seriously you need to relearn some basics
Oh okay sorry
They arent static but the thing is every character has its instance of it
between what? I don't follow.
every character has an instance of BoostBag and their BoostBag is different
you can easily differs
Each character has a CharacterDefinition. a ChacterDefinition has a BoostConfig object on it (or whatever you call it).
None of the runtime data lives in BoostConfig (or anywhere in CharacterDefinition at all)
It's all read-only data.
yes but all of my characters have a Shooting Component but I want that only ONE of them has access to a method that allows him to have a double shot
for example
Hey guys, sorry for bothering you... But I am working on a game and I have successfully written a code to make a prefab (card) use an image stored in a specific folder (which I use for the card images). The code was working properly in my first project, but it got all messed up after I try to install LeanTween, I made a new project and copied all the scripts I was using there, but now I am getting an error with the script that loads the image of the card, it is making the right path, but somehow it isnt able to locate the images... Could somebody help me? 
the coroutine for Boost.DoubleShot should set something on the Shooting component that tells it to shoot two bullets at once
The folder name needs to be Resources not Cards_Resources
why would you let only one of them have access?
because it is its unique hability
like overwatch for example
Wdym?
if its unique the just do a if statement to check if he has double shoot to do it
overwatch characters are unique classes inheriting from a base class called Character
Steve meant exactly what he wrote.
https://docs.unity3d.com/ScriptReference/Resources.Load.html read this page carefully.
your code is looking for files in Resources/CardImages.
your folder is
oooh.
But that bool is going to be checked independently of the character
Thx...😅
okay i dont think we re speaking the same language anymore, you need some professional help
thats rude
The things you're saying do not make sense.
Every character will check if doubleShot is set to true
whats rude here, im being polite to tell someone else to walk you through this
It's true that this system means that your Character class needs to understand how to use all of the different kinds of boosts.
Creating an ability system where all of the logic is stored outside of the character class is harder.
It's more flexible, of course, but I don't think it's necessary here.
so It doesnt matter that everyone checks it although only one character is allowed to make it true?
an ability system stored outside of character class is simply impossible
Yes, that's the idea.
well, it's plausible, but it gets more and more challenging as you extract more and more logic
at least that unique class inherit from some interfaces, or base class
that calls the damm functions
okay, I thought it would be a little bit dirty that every character does that comprobation
oh I know what you need
delegates
dark magic
yes, delegate types allow you pass entire functions around as data
what is this dark magic you are introducing me
this is useful for creating complex behavior
is it useful for this habilities I am trying to implement?
yes
Okay lets see what spells I can learn
Thanks guys!
However, in order to make the roster, should I make each character a prefab?
this shit hit hard
however I have to figure out how to use them for my script
making each character a prefab will let you attach per-character components to them easily
and also set up references
Okay, so it is a good idea then, thanks!
do you know any way to implkement delegates to the hability stuff
Hello. Could someone help? Sometimes it starts to substract from x from gameobject very fast sometimes it works normally
!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 "works normally"
https://hastebin.com/share/ubazuboyag.csharp So this code should make it so when the player touches a object with tag Respawn, It decreases the alpha until it hits 0, sets the player to the lastCheckpoint, and puts the alpha back at 255. and it works great, until I touch the respawn again, which it doesnt do the Coroutine again
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
anyone know why?
!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.
Yeah I used hastebin... is there a problem with that?
im using it for my own knowledge lmao
OH lmao mb
np
You have nested while loops
So won't it keep going forever?
With the way the outer loop condition is set up?
Oh yeah I guess so
Ive changed it so it works everytime but it doesnt set the currentColors back to 255
{
Color currentColor = rend.material.color;
Color currentColor2 = rend2.material.color;
while (currentColor.a > 0)
{
currentColor.a -= 5f * Time.deltaTime;
currentColor2.a -= 5f * Time.deltaTime;
currentColor.a = Mathf.Max(0f, currentColor.a);
currentColor2.a = Mathf.Max(0f, currentColor.a);
rend.material.color = currentColor;
rend2.material.color = currentColor2;
yield return null;
}
// Alpha is now 0, set position to lastCheckpoint
transform.position = lastCheckpoint;
currentColor.a = 255;
currentColor2.a = 255;
}```
well you're just setting your local color variable to 255
you're not actually changing the renderer color
but isnt currentColor = to the rendererColor
it's just a Color struct
it's not related to the renderer
there's a reason you are doing rend.material.color = currentColor; inside the loop
without that, it won't affect the renderer
should I move that to the end?
it would need to be in both places the way you have this written
isnt color 0-1 ?
every 0.25 of secund substract 1 from y from rotation
but it will work the same
what If i defined currentColor in start
you should define something like a normalColor in Start, sure
you still want currentColor inside the coroutine
and at the end you can set the renderer color back to the normal color
so define normalcolor as 255 and then set renderer color = normal color
just do this
void Start() {
normalColor = myRenderer.color;
}```
you don't need to hardcode any numbers
telling me renderer does not contain a defenition for color
Just a overall doubt, I just learned about "enum" so I can just like give somewhat of a tag to something with if right? How is this different than just storing this information as a string?
Can't misspell enum names, if you do, you get a clear compiler error. It's not the case with strings
Plus, they're "lighter", as they're numbers under the hood
rend.material.color
sorry, as in your other code
thank you
So it is just for comodity and a bit of performance?
Yes, they're both safer than using strings, and more explicit than using raw numbers (since you name them)
{
Color currentColor = rend.material.color;
Color currentColor2 = rend2.material.color;
while (currentColor.a > 0)
{
currentColor.a -= 5f * Time.deltaTime;
currentColor2.a -= 5f * Time.deltaTime;
currentColor.a = Mathf.Max(0f, currentColor.a);
currentColor2.a = Mathf.Max(0f, currentColor.a);
rend.material.color = currentColor;
rend2.material.color = currentColor2;
yield return null;
}
// Alpha is now 0, set position to lastCheckpoint
transform.position = lastCheckpoint;
currentColor.a = normalColor.a;
currentColor2.a = normalColor.a;
}``` I set normalColor = rend.material.color, so I feel like this should be working but its still not reseting the alpha to 255 again
You're not putting the color back into the material, like you're doing inside the loop
This is required as currentColor is a local variable which has no relation whatsoever to the material's color
what can be the cause of UI buttons workingh inconsistently(soemetimes when i press mybutton it isntantly works whuile sometimes i have to press it 10 times) the selected and hover effect of the button do get registered tho
I am completely new to unity c#, can someone dm me
No, if you have a question post it here for everyone to see
where should I learn unity and c#? there are bunch of different tutorial from different people and everyone uses different way/method to make something work, I am just confused, I want to follow one man who can teach and explain in one way.
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
This is a more general programming issue than just unity but I have the vector from the player to the mouse click lets say (350, -275) I need to be able to simplify that so the bullet only moves about 5 pixels a milisecond, I need to "normalize" the vector but I cannot have decimals for either value, how should I do this?
Unity has a normalize function for vectors
normalize the vector, and move with the desired speed, yes.
I cannot have decimals for either value
Not possible to normalize a vector with these restrictions. unless it's facing in one of the cardinal directions
ok, what is normalizing? I want to build my own function
ty
Makes it a magnitude of 1
normalizing a vector is getting a vector in the same direction but with length 1.
That's not possible with integer-only components except for the 4 cardinal directions.
okay thanks I'll see what I can do with that, I'm trying to make a game in VB for school, a bit of a pain
but I get to flex on people so it's worth it
could someone give me first person script please
You were already told nobody is going to hand you free work. If you have errors or issues with your code, you can share it with specific questions.
nvm
sorry
Have you gone through !learn?
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
bro ima just copy and paste my script
Bad idea
here
Oh, you mean put yours script here? Ok, we can look at it
finally you understand me
I misunderstood one very vague thing you said
Which was in response to something I asked that you ignored
Have you gone through learn?
is it normal to have mathmatica as one of the languages...?
I guess, if there is a C# package that can run Mathematica expressions or vice-versa
It's not uncommon for a single repository to have multiple languages
guys that's a variable in my movement script of my player and I'd want to access it from a script of a prefab, how can I do it? I already have the player object in my prefab's script, maybe it will be helpful someway
oh alright then...
Script of a prefab?
Prefabs don't exist (they are just files; blueprints) so they can't really do anything
If you mean an INSTANCE of a prefab, then use one of the methods here
https://unity.huh.how/references
It is a script, which is used as a component.
The issue is prefab vs instance. Not the word script
don't use Find please 😵💫
what do you suggest instead?
Read the link I sent
It shows every method. But yeah, never use Find()
It is never necessary
At the very least use FindObjectOfType, but even that should be avoided
hey im making some dumb horse racing game on 2d. they all travel the same speed no matter what. the randSpeed 1 - 4 are set to random.range 10-30. They still move the same speed.
the code:
// IN START FUNCTION:
randSpeed1 = Random.Range(10, 30);
randSpeed2 = Random.Range(10, 30);
randSpeed3 = Random.Range(10, 30);
randSpeed4 = Random.Range(10, 30);
// IN FIXEDUPDATE FUNCTION
Horse1.transform.position = Vector3.SmoothDamp(Horse1.transform.position, End4.transform.position, ref velocity, randSpeed1);
Horse2.transform.position = Vector3.SmoothDamp(Horse2.transform.position, End3.transform.position, ref velocity, randSpeed2);
Horse3.transform.position = Vector3.SmoothDamp(Horse3.transform.position, End2.transform.position, ref velocity, randSpeed3);
Horse4.transform.position = Vector3.SmoothDamp(Horse4.transform.position, End1.transform.position, ref velocity, randSpeed4);
Please tell me where I went wrong because I'm really confused
You use the same ref velocity variable, so yep they're going to have the same velocity. You need 4 distinct variables.
oh ffs. thanks
my brains just not on haha. thank you
guys this script has error but i cant fix it can someone help please try saying whats wrong with the script using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FirstPersonCamera : MonoBehaviour
{
// Variables
public Transform player;
public float mouseSensitivity = 2f;
float cameraVerticalRotation = 0f;
bool lockedCursor = true;
void Start()
{
// Lock and Hide the Cursor
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
// Collect Mouse Input
float inputX = Input.GetAxis("Mouse X")*mouseSensitivity;
float inputY = Input.GetAxis("Mouse Y")*mouseSensitivity;
// Rotate the Camera around its local X axis
cameraVerticalRotation -= inputY;
cameraVerticalRotation = Mathf.Clamp(cameraVerticalRotation, -90f, 90f);
transform.localEulerAngles = Vector3.right * cameraVerticalRotation;
// Rotate the Player Object and the Camera around its Y axis
player.Rotate(Vector3.up * inputX);
}
}
!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.
oh ok
Use a code block or a paste website to post code, Discord interprets some characters for formatting
oki
@summer stump that doesn't work, am I missing something
Yes, the syntax is completely wrong
Did you look up the docs?
Where did you get that from? It's a wild guess
yeah you have to write the type of the variable and then idk
Well 1) the type goes between angle brackets
2) you don't put the variable name inside the method
yo can you help me with this script like you said earlier
and how does it know which variable to pick
Will you answer the question I asked twice?
Have you gone through learn?
It doesn't
That's not what it does
look nvm just forget this
Ok best of luck then
I will remember you don't want help in the future
but if it doesn't know I will never get the exact variable or I'm missing smth
You are missing something
First, you get a reference to the component instance
Which is what FindObjectOfType does
Then you use dot notation to access the variable from that reference
Look at the docs. It has example code
It tells you exactly what to do
The bullets destroy stuff inseted of getting destroyed
collision.gameObject is the thing it hits
Not itself
but if I have already the object can I access the variable via dot?
FindObjectOfType GIVES YOU THE OBJECT
Ohh.
first !ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
oh but I already have the object, so can I access it via dot
you named your class same as unity method too
From the docs
As we said, never use Find
The whole point of this discussion was to get you to not use Find. That was it
my enemy is following something weird for some reason heres the screenshots and code https://hastebin.com/share/ilorenalij.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
So what is suppose to be there insted of GameObject?
gameObject
Instead of collision.gameObject
I mean, there is a lot wrong with that code. But that one change will make the thing attached to that script get destroyed if it collides with something (ANYTHING) instead of the thing it collides with getting destroyed
hey guys, im new to unity programming and trying to learn online. ive been stuck for the past 2 days trying to figure out how to assign these animations to an actual animator script, when i click on move lets say, i can see a preview of the move but when i write the code and finish the animator my character stays idle. can anyone help?
Oh! I missed that! @lethal bolt , be sure to rename the class and configure your IDE
If I am making a turn based game, should I make each turn in the same scene and use two cameras for each player's area?
or should this be broken up into two scenes
for each player
yea
na why 
idk
I would say the former definitely
You could just use cinemachine to have it move back and forth easily, instead of two cameras
i copied the function from a tutorial (added a bit myself) but i don't understand it's purpose for the inputfield
but I mean, it works fine, why not use it, I mean I' d want an explaintation too. And how can I access the variable of the object, I'm really struggling so hard 🥲
it is toggled on the enter of the input
I think doing FindObject once in awake is acceptable,
better than any of the string ones imo
nvm i just thought about it
Hi I'm trying to convert a 3D model animation into a 2D animation, is it possible?
Is there a cool mode to get a object to rotate inwards towards a point quicker and quicker?
I have found transform.RotateAround, but that is not really what i'm looking for
probably not, unless you find a way to record transforms and transfer back
I'm looking for something like this
With the speed going up the closer to the middle
worth cheecking out
https://medium.com/@indivisibleparticles/a-simple-way-to-move-an-object-in-a-spiral-around-a-point-in-unity-bbf3fbab21f9
We used this piece of code in our game Space Loop. We wanted to implement an object that wouldn’t fall into the black hole in a straight…
Find is brittle and expensive. Very prone to errors.
Simply doing player.variableYouWant will give you the variable you want
Referencing and dot notation are the absolute basics of c#, next to simply knowing what an int or bool are. So I recommend doing a c# course
And then maybe !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Yeah, trying to get them to switch from Find with a string to FindObjectOfType<T>()
Oh I see now, ty and btw it doesn't work, it give me errors
I'm pretty familiar with classes, I usually code in cpp but Unity is a bit different
Unity is absolutely no different than c#, and in this respect c# isn't so different from cpp (of course slightly different)
Show the error to get help of course
I just have a question
to learn code should i just work on random projects and keep copying code till i memorize it
or should i put time learning the coding language alone
What part of writing code do you need learning?
The Unity api or the c# language?
c#
I'll for sure do it tomorrow, I alrady went to bed, can I dm you or will I disturb you?
you do neither of those.
You learn logic and analysis then you learn to convert that to a programming language
Are you coming from another language or are you entirely new to programming?
entirely new
i know netiher of that
i am at the first starting point
I don't do DMs. Best to just ask here. I am far from the most experienced person, and there will always be someone around to help
I've got to run.
They gave you a good first starting point
Neither of what you said is a good place to start. Don't do random projects or copy to learn
alr man, anyway tysm for the help, have a great day
!learn will guide you @brisk flume
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
If you want
!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.
oh sure i will look at them appreciate it
I feel like I'm being inefficient with the constant if statements. Is this supposed to look like this or could I refactor something better?
private void MoveSelectedCharacter() {
bool hasCharacterOnTile = _gridController.GetNodeFromCoordinatePosition(_gridController.GetCoordinatePosition()).hasUnitOnNode;
if (_battleManager.GetBattleState().Equals(BattleManager.BattleState.PlayerMove)){
if (selectedCharacter != null) {
if (selectedCharacter.IsSelected() && IsTileTraversible() && !hasCharacterOnTile) {
if (_gridController.GetNodeFromWorldPosition().isHighlightedForMovement) {
_gridController.RemoveHighlightFromTiles();
selectedCharacter.MoveCharacter(_gridController.GetWorldPosition());
Vector3Int characterPos = selectedCharacter.GetCharacterCoordPos();
_gridController.HighlightMovementRangeTiles(characterPos, selectedCharacter.GetCharacterSO().movementRange);
}
}
}
}
}```
Hey everyone up and coming huge vr developer here. I need help generating a random number from blah to blah, and excluding a list of numbers i could add to... help is EXTREMEly appreciated k thanks
depends the numbers
you could potentially have an array of int and pick random entry
or do you mean add them as excluded after generating ?
so im spawning spiders to random positions, and i dont want the same position twice
so im trying to make a gmod phys gun in unity and im struggling. I've gotten up to this point and tried a bunch of different approaches but im honestly not sure. Any ideas?
{
if (fps.viewHit.rigidbody != null)
{
Rigidbody rb = fps.viewHit.rigidbody;
rb.transform.position =
}
}```
hence the exluding of random numbers 1-8 which is 1-8 emty game ob jects i use as positions
put the points inside a list, then each enemy takes a random spawn point . no need for numbers
i know this is simple to execute but how would you go about making a toggle variable which dictates who's turn it is between two players
when enemy has picked a point, remove it from that list so next spider wont have it in random index
like i could do a boolean which is on (for p1 turn) and off (for p2 turn)
well you could make a bool
isPlayerOneTurn = true
or make an enum
@rich adder how would the points in the list look as vector3?
sorry im anoob
for now
thanks
nah you have transforms right ?
any idea what i could be doing wrong
yeah i load in the gameobjects in the editor then get it in code like pos3.transform.position
yeah add them to a List<Transform> spawnPoints
each time you take the spawn point , do spawnPoint.Remove(theChosenPoint)
weaponfire needs to be public
serialisefield means its private but accessible through the editor
ur looking at wrong thing
alruight thanks mate could i dm you if i need help
weaponFired is the bool, it needs to be public yes
yeah but he can't access the bool if its not public right?
you can post here no probs
yes correct, the bool in that class has to be public
but the reference itself to WeaponFire script can be private
word
How would I go about make music fade out when I move away from it in 2D?
{
if (collision.gameObject.tag == "Player")
{
source2.Play();
StartCoroutine(moveWall());
gameObject.SetActive(false);
}``` Have this code on a stationary coin which when touching the player should play a sound, start a coroutine, and then turn off, but the collision isnt being triggered. I have no idea why
(I'm really new to game dev)
if you're using an audio source then you can use 3D sound settings and configure the rolloff which is basically the strength of audio by distance
it should work the same use the 3D sound setting make sure camera enters that zone
(Camera has Audio Listener)
@languid saffron
@rich adder hey if you're not too busy could i get your help with what i posted earlier?
debug the function first make sure its runing ,put a log
@rich adder Transform Position1 = pos1.transform;
spawnPoints.Add(Position1); this good? at start()
also how do i add the black text for code
in discord
!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.
spawnPoints.Add(Position1);```
it doesnt
spawnPoints.Add(pos1);
is there a reason yuo're not linking thise gameobjects at runtime ?
huh ?
I feel like im doing something wrong, each slingshot and shop has it's own script. My current issue is I am not sure how i will manage dividing everything into two and needing to access each slingshot and shop's script individually
do you have at least 1 rigidbody between the two colliders
judging from the hierarchy what would you change
this
gives an error Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from 'UnityEngine.GameObject' to 'UnityEngine.Transform' Assembly-CSharp, Assembly-CSharp.Player C:\Users\Anthony\Unity Games\EscapeRoom2\Assets\SpawnSpiders.cs 28 Active
coin has collider?
idk what that means
pos1 is a gameobject ?
also ur helping two people at a time thats talent
just put .transform
ah
what does that mean
*adhd brain
Both the coin and player have colliders if thats what u mean
can I see both colliders, on each object
which one has the script you sent
The coin
This good? (Camera also has Audio Listener, but when I move the object with the Audio Source across the map, I can still hear it perfectly)
does the player collide with coin
yes
you should be able to see the range of the sound in the editor, are you sure you're actually leaving its audio range?
where did you put log btw
@rich adder so how do i get a random spawn point for the spider? ``` float spawnNumber = Random.Range(1, 6);
if (spawnNumber == 1)
{
spiderSpawn.transform.position = pos1.transform.position;
spiderNumber -= 1;
spawnPoints.Remove(pos1.transform);``` this me rn
before the source2.play
How can i add on the particle on inpact
also im pretty sure the audio level needs to reach 0 at some point in the graph for it to not be heard anymore, what it looks like now is the audio just gets quieter until i certain point no matter the distance
var randomIndex = Random.Range(0, spawnPoints.Count)
var randomSpawn = spawnPoints[randomIndex]
spawnPoins.Remove(randomSpawn)
oh..
How would I go about doing that?
Instantiate(partictleSys, transform.position, Quaternion.identity)
put it before the if statement
compiler error
wut
cannot convert Transform to Vector3
still doesnt fire
ah you're right
you put before if statement, screenshot whole console in playmode
do you see the red line on the graph?
id appreciate advice cause feel like it's going to be very messy and confusing. Each slingshot and shop is using the same script, just in different objects
that needs to reach the bottom at some point for the audio to not be heard at a certain distance
this probably isnt what u mean but
it doesnt appear
yeah like that
i can still hear it
that graph indicates the audio level over distance
making sure its not collapsed
ah man navarone is on it
When it's set to 3D I can't hear it even when I'm near it
does your camera have AudioListener ?
Yep
@rich adder spiderSpawn.transform.position = spawnPoints[randomIndex]; this giving me an erro
Severity Code Description Project File Line Suppression State
Error CS0029 Cannot implicitly convert type 'UnityEngine.Transform' to 'UnityEngine.Vector3' Assembly-CSharp, Assembly-CSharp.Player C:\Users\Anthony\Unity Games\EscapeRoom2\Assets\SpawnSpiders.cs 48 Active
randomIndex.transform.position
❤️
spawnPoints[randomIndex] is a Transform
you need to get its property .position if you want v3
@rich adder idk if u saw it or not but (sorry for being a bother)
if I want to register the target transform for my bullet but without relying in the editor to assign it
how are you moving player ?
pass it through whatever spawns the bullet
let me just hastebin my code navarone
but then I am passing the shooter vector not the target no?
@rich adder https://hastebin.com/share/orekavexag.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
no..is the target a transform?
yes
is your player a kinematic rigidbody ?
what I mean is that if I pass the transform of whoever shoots Im not passing the target
no its dynamic
how can i move the root bone of two bone ik constraint with the tip still working?
i never said pass the the one who shoots, Im saying whoever has the reference to target transform pass it to the bullet during spawn
like i need to be able to move Arm.L through code with the ik still working properly
but then Im relying again on the editor again because the reference of the target in the shooter script is passed through editor
well you need a way to already have target..
depends on many things
like if you're doing a ray you can already find target
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
okay this is it
I had some code that was doing absolutely nothign
maybe try making coin collider a trigger
and use OnTriggerEnter2D
if it has rigidbody it can calls it both colliders
oh ok
make sure its dynamic lol
I only used .MovePosition with kinematic thats why I got confused
okay it worked
kinda
theres some issues but its better
ill probably be back in here in liek 5 minutes lmao
wdym some issues?
the audioSource isnt playing
make sure scene/window isnt muted
The thing is that I am making a fighting game and I want the objects in scene to already have some references, should I make the fighters prefabs and instantiate them whenever the fight starts or should I make 2 game objects in scene already???
heres this to help if u need
will you be using more scenes ?
navarone
Yeah maybe, menu for the play mode selection, starting screen
so which part was working
those have nothing to do with the players or spawning them then
Excuse me
What is moveDirection.sqrMagnitude ?
Character Selector as well
it does everything but play the audio
it sets off the moveWall and it sets the coin to be not active
then you would pass that down from character selection to insert the references
So I shouldnt make them prefabs?
how do i change the root's position without affecting the rest of the ik?cs private void LateUpdate() { leftArm.position = targetRightArmPosition.position; rightArm.position = targetLeftArmPosition.position; }
u can see in the video
that it moves the whole arm now
and the ik doesnt go to the target
i just want to change the root's position and not its children
are the two characters only ?
Think of Street Fighter for example
thats why the coroutine not working if you disable it
two characters fighting from a character roster
yield return null;``` I want it to move the wall gradually im sure this code is wrong
i just have no idea why the audio source isnt playing
the audiosource is on the coin and ur disabling it
whatever system you have to pick character will pass on to the thing that spawns char , the references to each other
sorry I dont understand, you mean that when I pick the character that passes the references? how?
how else do you plan on spawning them
yeah but the thing is
Should I make my characters of the roster prefabs?
so they can be instantiated whenever fight starts
or should I make two game objects already in the fight scene?
how would you have two things in the scene that aren't chosen yet
unless you have some blank prefab then load the player data like an SO
I have the player data as SO but even with that I think the prefab way is correct right?
there is no wrong or right answer here, they're both valid. find out whichever one is easier for you
okay thanks
The only problem of making them prefab is
how can I assign the reference to target transform
because prefabs are in assets, not in Scene?
yes, n like i said before whatever spawns the assets has reference to both objects do an Init method and pass references on spawn
Okay thanks, now I get it!
why does sineWaze make the movement so extreme even if waveDensity and intensity are at something very small like 0.1
the obejcts beign scattered
I can provide more context if needed
I dont know if it is okay to use the same two scripts twice on two separate objects
Sine wave would be a function for setting position not for velocity
thanks i figured out tho, here is the new code for those who r interested
I've decided to create a fresh project with the simplest form of the thing I had an issue with to isolate the source of the problem
changing the position of an object through script isn't working for me for some reason
Show your code?
how on earth are they still falling (although very slowly) if their gravity scale is 0?
can you not just set their movement to kinematic to keep gravity from affecting them?
kinematic only lets code affect the movement of the objects instead of dynamic, dynamic allows gravity and code to affect objects.
Does the object have a CharacterController on it
no
Show code then
it's a UI Image
!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.
ok on sec
so I got it working in a fresh project but Idk why it's not working in my main project
here's the code
Can you show the image above, but not cropped
A lot of important info is cut off
yeah
More than 10 lines imo
If you have to ask, that
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
didn't mean to comment the update line
That is longer than 10 lines lol. It is a very large code block
Okay, so I'm guessing MoveCardHovered is the one that's not working? If you remove those OnPointer methods does it start working?
yeah MoveCardHovered doesn't work properly
this is the debug log from the positions
So, if you put this log after setting the position, does it display the same value for both?
Okay, then it's pretty clear something else is moving it after this function runs
something resets the position before the next frame
Do you have an animation on the object you're moving?
I do
Does the animation have a position property on it?
yes
Then it's the reason why you can't set the position in code
even if no animations are playing?
I don't have any properties changed on the default
Are you sure it's the one playing? Have you run the game and check the animator to see which animation is actually running though?
i'll double check the animator during runtime
Either way, code not moving something means something is overriding. Most cases, it is an animation running, otherwise, you have code resetting it elsewhere
gotcha, thanks for the help
how does one change the value "0.7" via code?
@frosty hound Would a Grid Layout Group effect the position if I Instantiate a copy of one of the child objects in the grid layout group but as a child object of another canvas? I was under the impression the only time the position was driven by the Grid Layout Group was when it's a child object of the GameObject with that component.
also if the ping is inappropriate lmk I'm new to this way of getting help
Well, that canvas would be part of the layout group
You're fine. They were helping you already
Pings to uninvolved people is not good.
The GridLayout affects child objects. If you're spawning it as a child of a different canvas entirely it should be fine (as long as that canvas is not itself part of a layout group)
this is the object with the grid layout group
the display canvas is where I instantiate the clone
I'm going to run through all my scripts and make sure it's not some of my code driving the position
does anyone know how to use a field watch in Rider?
if I could watch the position after my code I could potentially see what code is changing the value
I tried googling this but the answers were not clear on whether this is possible or not
thanks, also would naming the pramater same as the animation could cause some problems with this?
is there a reason as to why i cant drag the animation called "HeartIdle" into the "anim" section of the script component?
Because you can't drag an AnimationClip into a slot for an Animation (which is a component)
damn what the hell is an Animation then
ok so
i just added an animation component
dragged the clip in there
then draggen the component into that slot in the ss
thats how its supposed to be done?
You shouldn't use the Animation component. You should use the Animator
Animation is a legacy system. It may seem easier but once you do anything more complex than playing one animation straight through it's gonna get more complicated
so through the animator i get the right animation clip with some code
If you want to reference an animation with that clip in it, sure.it really depends what you're trying to accomplish here
i just want to set its speed to 0.4
i followed the docs sent above somewhere
If you're using Animator generally there's not a good reason to reference an animation clip
You would use Animator parameters for this
In the state you can set the speed to be read from a parameter
Then you set that parameter from your code
No reason to reference any clips
Yes
for when the animation should be played
You can use multiple parameters for different things
alright ill try to cook
i dont get what im supposed to do, here is my code: https://gdl.space/ixaxekokod.cs
...
i do set the animator.SetFloat("HeartIdleFloat", 0.4f); correectly ig
but idk how to use that to then set the speed of the animation to the value of the float parameter
Next to speed in the animator, is there a checkbox for "Parameter"
Hey, can anyone help me out with this? So I downloaded probuilder in unity but it doesn't show the tools tab after I downloaded it, anyone know how to fix it>
Hey guys. I’m working on an interesting project simulating cars precisely. So, I have a function that runs and matches up the rotation of the wheels to the speed of the car and vice versa (I’ll take slip into consideration later), but my problem is that when cars steer, the car rotates a little bit as you turn. But in Unity, since I’m custom programming the rotation and movement of the car, I also have to code the rotation of the car. What’s the best way to go about the steering?
Use local rotation.
Could you help me with this?
Is it supposed to show the tab on the particular package version?
And if so, do you have any compile errors?
It's just supposed to add a tools bar after being downloaded.
when you drag the scroll rect, there should be a value indicating how much u dragged , whats that?
should be a normalized value?
What about my second question?
Wdym. For what?
I don't think so
Can you check..?
Look in the unity console.
Can you send a picture of what it looks like?
You should always know so. I recommend generally just keeping the console open at all times
Click the bar at the very bottom of Unity
It will open it
Well, you'll need to fix these errors first.
You read the error message, understand it, check the code that throws it and fix accordingly.
Alright.
Every one is of course different
The red ones are errors
Yellow are warnings
Grey or whatever are just logs
Is there any way to constrain one gameobject to 4 others
Cause I want my wheels to move when I’m steering and I want the chassis to follow along like a normal car
Use wheel colliders
im getting this error on my scene switch script
Cannot load scene: Invalid scene name (empty string) and invalid build index -1
UnityEngine.SceneManagement.SceneManager:LoadScene (string)
{
SceneManager.LoadScene(SV.currentScene);
}``` thats the function that makes the game reload the scene and SV.currentScene is a variable on a scriptable object that is assigned a value on start
What value does it have assigned?
Im doing custom steering. Custom everything. Wheel colliders is cheating
Do you have scenes added in the build menu?
My biggest problem though is chassis rotation
I haven’t come up with any solution
My only idea was to calculate the ackerman center point and instantiate a gameobject and rotate around it but that doesn’t seem pretty efficient
Well, good luck then.
Vehicles physics are pretty complex thing. Definitely not something a beginner should be doing.
I’ve used Unity a lot
And game developed a lot
i found the problem its that it isnt being assigned to the variable on start ``` public int sceneIndex = 0;
public string currentScene;
public string[] Scenes;
// Start is called before the first frame update
void Start()
{
currentScene = Scenes[0];
}```
thats how i try to assign it but that doesnt work for some reason
Then maybe move to general or advanced channel. And provide more details in your issue and setup.
Debug
Any easy way to stop the "glitch" that I am seeing in the video, basically I have a dialoge system where when you hit a box collider it starts but if you leave and reenter it makes that weird visual thingy and I couldnt think of a good way to stop it, there is my code as well. Ideally it just restarts every time you enter and loses the first bit of text if that makes any sense. Any ideas would be greatly appreciated thanks!
yeah its causing an error where i assign the variable cause no debugs print to the console after that statement thats a pic of the array being set in the editor but for some reason it doesnt want to assign to that variable
Share the error details...
ArgumentNullException: Value cannot be null.
Parameter name: _unity_self
Expand it a bit more
Hi, I need your help guys.
Im making a quiz game and the score system doesn't seem to work. The text should display "00" and when the player picked the correct answer, it should add 1 to the text, so it should be "01". What code should I add
Here's the scripts:
!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.
you have to past your code like this
They should link to their code, as it is large.
yeah i cant paste it LOL mb
Here, pls help me cuz its for my project and I'm really struggling with the increment
Hmm... This error is probably unrelated. Does it happen again if you clear the console and launch the game?
Everytime the public void correct method is called, it should add up to the text (repText)
I am really struggling to get something i imagine should be simple enough to do
Basically, when the player controlled tank destroys a mysterycrate with its bluerounds, 1 of 3 random effects should occur
1Crate explodes and damages thing nearby
2tank and blue rounds get bigger and faster and do more damage for 10-15 s3conds
3. Player tank recovers 10 durability(health)
Anyone able/willing to help?
This is for my final game design course project, due soon, and i still need to add difficulty settings and ui TnT
yo someone help my player is fading through textures
oke i change speed
and its works
not quite sure what the problem is, but for something like this its best to design it out with a flowchart before you start coding
I could send the scripts or export the game assets if it helps
But what do you mean by designing it out with a flow chart?
like this
helps you map out all your references and objects
designing a system with nothing but your brain is impossible
for example
void Update()
{
if (!isInit) { return; }
if (!isExecuted)
{
float dragThreshold = m_recycleScrollRect.content.rect.height * 0.05f;
if (m_recycleScrollRect.content.anchoredPosition.y < -dragThreshold)
{
StartCoroutine(test());
isExecuted = true;
}
}
}
IEnumerator<WaitForSeconds> test()
{
Debug.Log($">>> parsed");
yield return new WaitForSeconds(1);
m_history = m_history.OrderByDescending(m_history => m_history.updateAt).ToList();//sort by descending
}```
is there any ways to do the same thing without using update at all?
Do the same what thing?
this code is to simulate modern app scrolling
Use string formatting
ToString("D2")
when you are on ur phone, like on google chrome app, if you are on the top of the website, you scroll even further up, it will refresh right?
im asked to do the same thing to the UI
however, this UI does not even have a scrollbar, so you cant use verticalscroll.value
This is less code but more unity stuff
test() is the function for refresh
You could use the IPointerDragHandler and similar interfaces to handle the dragging.
but with complex animations do you have to have a trigger for each individual Transition?
If you want to trigger the transition from code, yes.
Otherwise, no.
Mhmm
Maybe I can explain it like this
Lets say in the code
if they press W I want them to go forward
I odnt care what state they are in
just get them moving forward
But if I set all of the conditions on each transition to walk what one will it use?
This sounds more like an #🏃┃animation question honestly
Wdym? It would use the first valid transition from current state to the target state.
Oh okay
so If the current state is walking
it would go from walking to idle no matter what
even if another transition uses the same trigger?
Confirm the correct API in the documentation.
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.EventSystems.IDragHandler.html
If the other transition is from a different state, it obviously wouldn't run.
Lunch?
It's a meal generally eaten around mid-day
In the update function, everytime my ray hits the ground I want it to lerp between feet.transform.position and hitpos. How could I do this?
the code works but I just want to implement lerp (i tried and it failed horribly)
I would honestly consider smoothdamp or movetowards for this
But this helps with lerp, one sec
Movetowards was my fix for this, thanks man
alot easier than lerp lol
in east asia, we have breakfast (6am-10am) , lunch (11am-2pm) , and dinner (6pm-8pm)
we also have midnight snack(meal) tho
breakfast is super light meal, dinner eats the most
i guess lunch is more like a brunch in european countries?
update on my problem:
- Animator component changes the position of my object after I change it each frame
- I'm not sure what part of the animator is doing this, the default state doesn't have an animation
- Does an Animator component force positional values even after an animation finishes playing? (it's not set to loop)
doing further investigation
sorry forgot to say thanks, this was exactly what I was looking for 🙂
Hey, I have a minor beginner doubt regarding C#.
So, I was working on a small game for my first game. It's a flappy bird game. Here's the update function
void Update()
{
myRigidBody.velocity = Vector2.up * 10;
print(Vector2.up);
}
Here, is the Vector2.up always constant? It's always (0, 1) when I print it.
When in doubt, check documentation. https://docs.unity3d.com/ScriptReference/Vector2-up.html
It's the green/Y component of the vector in world space
So it will be 0, 1
So yes, because it's world space and not object space, it will always be constant. If it's object space, then it will also be constant unless a force or rotation is applied
I uploaded my game to dropbox so i can access it on another computer but it skipped some files as they were deemed as empty
could this affect the upload at all
idk but they are of the file type rsp2 and mvfrm
true
if dropbox says they are empty surely they are empty right
Some files are used as cache
Which fill up on runtime
But cache can be deleted
okay cool
also i just uploaded the self titled folder of the game
should i also upload the data folder
If the game runs, then it works
ok thanks
Is there any advice for this
or is ther not enough context
Thanks. I was confused a bit onto this. As I asked Claude (I know not the brightest idea) and it said it's not a constant and started typing an essay. Docs https://docs.unity3d.com/ScriptReference/Vector2.html say it's a shorthand for Vector2(0, 1). I'm assuming it's a (or like a) constructor?
It's a property that returns a static field. https://github.com/Unity-Technologies/UnityCsReference/blob/6a26bc151b158aa1bba01019d97d932710fd8d6e/Runtime/Export/Math/Vector2.cs#L414
Assets\Scripts\Purchaser.cs(9,45): error CS0535: 'Purchaser' does not implement interface member 'IStoreListener.OnInitializeFailed(InitializationFailureReason, string)'
!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.
Interface methods and properties must be implemented. That's the point of an interface.
The easiest fix is to define the method in this case and leave it empty, but that's obviously not the point.
sorry but i did not understand
Then consider learning how interfaces work in c#
How Do i access depth of field and motion blur in script?
Access profile, then depth of field
lemme see
also don't use Find(""); - ever
Hey guys
I have a parent class
I have 2 classes inherit from this class
Now I put a list in the parent class to store whatever collided with the 2 classes (game object).
So will these classes share 1 single list or they still store stuff in 2 different lists ?
Classes are created with a new instance, so the data inside of it will also have a new instance. That would mean the list is also new.
If you want to share the list, you can make the list static to avoid it being part of an instance.
Then it will be a single list. Note that this means the list will always exist and in the event a class is removed or destroyed the list will continue to exist.
A better idea would be to have a general shared class that holds the list, and have the classes access its data. Then you can share the list.
A common way of having a shared class would be implementing a Singleton: https://unity.huh.how/references/singletons
Why tho and what I use instead of it
Find type methods are kind of like reflection in c#. You have a general method to find anything in the application, but it is incredibly slow to do something like this. It's also very prone to errors if you try to find by string or in general because if the result does not exist it's not clear why.
There are better ways to find what you want. If you have a single instance of something, and I assume that's the case here, then perhaps also try accessing it by singleton: #💻┃code-beginner message
Singletons are not always the answer but if you're certain you will only ever need one instance you can use this.
Ik this using instance but then how do i find a component?
That's explained on the page about the singleton
Lemme sre
I'm doing atan(y/x) to fid the angle from the center
I don't know what is wrong with that but it returns a decimal every time
math checks out wth
What's your expectation and what actually happens?
whats up with those equations at the bottom too 🤔 were you trying to get rid of the 1 as a denominator
https://docs.unity3d.com/ScriptReference/Mathf.Atan.html
also the value is in radians. convert to degrees to get what you want, even though you havent described what you want
I would like to ask how i would calculate if there is a wall in front of my enemy so it will take another route to get to the player under here is the Enemy script and the target Transform is just the Player
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
[SerializeField]
private Transform target;
[SerializeField]
private float speed = 2f;
private float minDistance = 1f;
private float range;
void Update()
{
range = Vector2.Distance(transform.position, target.position);
if (range > minDistance)
{
transform.position = Vector2.MoveTowards(transform.position, target.position, speed * Time.deltaTime);
}
}
}
Raycast forward from your enemy and see if it hits a wall.
probably best to use Nav mesh and let that do the heavy lifting
True but its in 2D and i have not played a lot with navmesh
I have only played with Navmesh in 3D
yeah, Unity Nav mesh won;'t work in 2D, you would need to use something like A* Pathfinding
but still a damn sight easier and better than trying to do it yourself
Should i use this?
yes, I would
Ok will do that thanks
wait, no
oh?
this one
https://arongranberg.com/astar/
ok will use that
but does it work for 2D?
yes, otherwise I would not have mentioned it
ok i will take a look at it
Guys how do i make a grid based movement
Now it looks like this but the ai does not move and idk if i made it right
i want to add IAP to my game. Any tutorial or documentation
BTW i moved my player a little so thats why the line does not connect
idk if you made it right either but I find it impossible to believe that you have read and understood the A* system in 12 minutes
Yea i dont but i dont have that much time to make it because its under a gamejam
I've been talking to some folks on the unity forums, and they said you can actually create scriptable object instances at runtime. Given that, would that make it possible to use SOs for randoml generated items that you can't possibly define before running the game?
rule one of doing game jams, only use stuff you already know how to implement. I think you need to look for an alternative route
Oh i did not know since its my second gamejam but i have a system but the ai will just walk into the wall and get stuck
this may be your best option then #💻┃code-beginner message
in future you will get better help if you disclose all relevant information when you ask a question
I am getting help
i want to add IAP to my game,but i dont know how to it?
Assets\Scripts\Purchaser.cs(9,41): error CS0535: 'Purchaser' does not implement interface member 'IStoreListener.OnInitializeFailed(InitializationFailureReason, string)' . i tryed but this error is coming
Actually, thinking about it now, one of the reasons I'm even using scriptable objects is so I can give items a prefab that they can spawn into the world using, since I can just drag and drop it through the editor. Is it possible to do that with regular classes too?
and if I instantiate a scriptable object at runtime for a randomly generated item, I won't be able to drag that prefab in the object, so i may have to do it in code
what did you try? Implementing the missing interface method?
whats the missing interface
not missing interface, missing interface method. This one, as clearly stated in the error message
'IStoreListener.OnInitializeFailed(InitializationFailureReason, string)'
So what i have to do i am so confused
had you read the docs about interfaces linked to you earlier you would know what to do
but you need to implement a method Exactly as shown in the message
Lol, what?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void Exit()
{
Application.Quit();
}
}
Common/Classic mistake
You dragged the wrong thing into the slot
Drag a GameObject with the script attached to it into the slot. Not the script itself
Should i create gameObject(prefab) to scene?
if I change some parts of the scriptable object script, do i need to create a new asset for it to update?
Not at all. You need an instance to call an instance method.
No
good good
Application.Quit();
Does it work?
Lol is working
But exit don`t
getting an error I've not seen before, but double clicking doesn't actually take me anywhere
read Application.Quit(); docs
literally the second line of the description
Shut down the running application. The Application.Quit call is ignored in the Editor.
Lol
how do i save my game so then i can covert it into zip and sumbit it into the dropbox
hmmm why i cant reference my asset?
Read the Resources.Load documentation
okie
I think they should make it quit the editor without saving 🙂
yea and close your PC aswell
and run sudo rm -rf /
and put it back in the box and mail it back to where it came from
so you have to place in Resources folder in order to reference it in code?
is that what the docs say?
the important word there is 'relative'. Any folder used in Resources.Load must be relative to a Resources folder
So I've got myself some inventory scriptable objects created, however I can't actually see their contents. My base inventory script is generic and these are more concrete types, but is there something I'm missing to properly see their contents?
https://hastebin.com/share/erobetajog.cpp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Since I've got a generic inventorySO script, with subclasses that inherit it and declare the type, then those become assets, is that why?
I am playing with NavMesh in 2D but it does not work since there isnt a navmesh also after i have baked there still isnt a navmesh
This is how my hierarchy looks
My teacher said not to use that
Then you can't use navmesh in 2D
huh?
Navmesh is for 3D only
Oh
Unless there's something I don't know
Well, you can fake 3d for the navmesh, but yeah, it's not intended to be used in 2d context.
Then i will try and use NavMeshPlus
im new to unity and game making in general, im trying to make a conveyor and put a 2d collider on my object and one on my conveyor.
private void OnCollisionStay2D(Collision2D collision)
{
print("collided");
}```
this is in my conveyor script for now, issue is it doesnt print anything
i tried giving the object a rigidbody2D which didnt work
the is a child of a gameobject (the child has the collider and the parent has one as well but for a different purpose)
the collider of the parent doesnt work for its purpose either
You would need at least one dynamic Rigidbody for this
And both objects need non trigger colliders
why non trigger?
can it be kinematic? i dont want gravity
Because that's how collisions work
If you don't want gravity just set gravity scale to 0
Kinematic is not for removing gravity
It must be dynamic
If it's a trigger there's no collision
oh
i thought trigger was to avoid pushing object out
Triggers are to have no physical collision
Just the ability to detect the overlap with OnTriggerEnter2D
oh then ig i just used the wrong collider
hello, does anyone know why my Pretest and Posttest scene wont appear in the build settings? ive already pressed "add open scene"
Hello, is there a way to get the rotation values of an object that are equal to the ones in the inspector that also works in builds. I know that there is this: UnityEditor.TransformUtils.GetInspectorRotation(gameObject.transform), but it doesn't work for builds.
I am currently using "transform.rotation.eulerAngles", but those values only go from 0 to 360 so they do not show how often the object rotated around itself.
m_LocalEulerAnglesHint: {x: 0, y: 23555, z: 0}
This is stored in the serialized data. I'm not sure it's going to exist in the built game at all.
errr help im trying to donwload like the tutorial projects from unity learn but i dont know which version it is i just downloaded another editor and im still getting this
so is there another way to get those values?
The Euler angles in the inspector aren't mean to be used that way. If you want to track the number of rotations you'll have to make your own Vector3 variable and use that instead
ok interesting I'll do it like that. Though i think there should be a way to get the values that are shown in the inspector. would make it a bit easier
do you actually have the scenes open for editing, though?
yeah that solved it tysm
I get the same with version 2022.
From my quick google it seems they aren't available for 2022.x.
Have you tried 2021.x or 2020.x?
use the 2021 LTS.