#💻┃code-beginner
1 messages · Page 180 of 1
im not sure how to put it since im new to unity but like how do i replace the model in general
!Code, you should know better by now
📃 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.
this is a code related channel
mb
My PC can run VS just fine but it runs VSC much quicker. VS is more productive for me tho 😭
Thats fair, though its non-executable example code to explain an approach, and didnt seem that long, but your probably right it could have been a link
you do have a point, VS can be very slow, I just turn off all the crap I don't need
VS community is free tho right?
yes
That's more than enough for an Indie dev
sure
VS and Unity are basically a match made in heaven
god help the poor Mac devs when VS for Mac depreciates
VSC is good for some coding projects due to its MASSIVE extension store but looking at a Unity standpoint, VS is the clear winner
Having a full IDE that is already configured to the game engine is just more productive
!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
There was an Eclipse plug-in many, many years ago, I wonder what ever happened to that
yep
Hello, i want the health value to be same with the max health value when i reload the screen. I decrease the maxHealth value by 10 when i clik a button. health should be equlized with maxHealth on start method in the playerHealth script. In short when i decrease the maxHealth, health value should be the same value as it is
This is StatsExchangeMenu script:
https://pastebin.pl/view/6522f52b
This is playerHealth Script:
https://pastebin.pl/view/e0dfa96a
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
It took like 10 minutes to configure (albeit, it isn't a lot but VS is just instant)
when i exit run time and hit play again, the values are equlized
10 minutes? Some people don't manage to do it in 10 days
I would use Visual Studio but it just doesn't like my hardware I guess. Constant freezes and slowdowns so I settle with VSCode
And I have a decent PC, mid-high tier
Although I think for VS you need the VS package from the unity editor you're using
My laptop can run VS and it has like 4 GB RAM
Which I don't have
Idk how to install it
Yeah my PC should be able to handle it, not sure what is wrong
Specs?
May need clarify what is the behaviour of it right now and what you want it to do. If you want to change the values in the editor then you need to expose the fields using [SerializeField]
3700X, 16GB ram
DDR4?
best do this
void Start()
{
// Add event listeners for button clicks
AddButtonClickListeners(healthButtonsParent);
AddButtonClickListeners(speedButtonsParent);
AddButtonClickListeners(damageButtonsParent);
LoadPlayerStats();
}
in Awake not start
My project is pretty huge though and it did complain about that at some point. Should try with a new project maybe and see if it makes a difference
all of it, or just LoadPlayerStats(); ?
Your specs should be more than enough 😭
4gb is nowhere near enough, you should have 8 or 16 at least
Evidently not
all of it
im at 16 too and unity + vs + windows is like 12 gigs, I'mma need to upgrade my stuff soon
What packages are y'all installing tf
if you have only 4gb you are using virtual memory which is disk based so very slow
It's fine
I'll clear out my extensions and configure VSC if things go south
Just like I did last time
My main issue with VS was opening the search menu in some files just made it freeze or ultra slowdown
Had lot of bloatware floating around anyway
double your memory, you will see the difference believe me
I'm aware. It isn't expensive either, but I've had my laptop for a decade and it's pretty beat up. Pretty hard to change the specs
I can buy a new one but this works just fine
unity has been doing to this to me too recently so I should probably start cleaning up my projects
With my "S" keycap being detached and half the screws on the case missing, thing still chugs along and runs most indie games at well over 120 Fps
And titles like TF2 which is my favorite shooter
You mean unity gets slow when you try to search something in unity?
If I want to play anything AAA I just have my console
Daamn, it worked! God i have been working on this for hours. I can't thank you enough man, you always help me. I really appreciate it 🙏
does anybody knowhow I can access the properties of a rigidbody through the script?
Titan Fall 2 reference
Team Fortress 2
yeah, like even just for thumbnails the thing crawls to a snail
remember script execution order
Titanfall would blow my laptop to shit
same
Amazing storyline tho
anyway how do I access the properties of something through a script?
like the drag of a rigidbody
Do you know how to get a reference to the rigidbody?
yeah
I have that
I just dont know how to access the properties under it
rigidbody.mass = 123; for example
Nothing special about it
(You replace rigidbody with your variable name here ofc)
So the manager doesn't need a GameObject and can do FixedUpdates?
Well, the List<Something> instances will be changed throughout the game, so I need to add and delete some instance.
For the time, I thought something like this?
I wish that every class that inherit Entity, would FixedUpdate their list of buff (buffs)
public abstract class Entity : MonoBehaviour
{
public Buffs buffs;
public virtual void Awake()
{
buffs = null;
}
public void FixedUpdate()
{
buffs.UpdateBuffs();
}
}
public class Stella : Entity
{
// Start is called before the first frame update
public override void Awake()
{
buffs = new Buffs(...);
}
}
public class Buffs
{
public List<Buff> buffList;
// Constructor
public Buffs( ... )
{
buffList = ...;
}
// Method
public void UpdateBuffs()
{
... // I decrease a TimeValue by 1 for each buff.
}
}
alr thnx
Currently, Stella will use the FixedUpdate of its parent class (Entity)
So it will indeed update its buffs list
Thank you for confirmation
Your intellisense would've probably already loaded if you had more RAM
Given that Windows itself recommends having 4gb for its own OS, you're in for a bad time with win11
yeah, lol, but look at what your ssd is doing
Yes, that's basically the biggest issue
Disk at 56%
@cunning rapids No off-topic media, please
All good 😅
Anyways, my case is getting pretty hot
VS works fine but I'd rather use VSC
!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.
Maybe check whether the panel is activated for the first time or if it's being reactivated
You can use a bool flag
ensure that the targetPosition is set only during the first activation of the panel, and subsequent activations will retain the existing targetPosition
This could be a cheap solution
private bool FirstActive = true;
private void OnEnable()
{
InitializeScrolling();
}
private void InitializeScrolling()
{
if (isFirstActivation)
{
targetPosition = contentPanel.anchoredPosition;
FirstActive = false;
}
}
it seems like the snap functionality is not being properly reinitialized when the panel is activated for the second time.
I could be completely wrong tho since it's hard for me to visualize the problem
Would images help?
Images, videos
ANything
Besides there are some much more seasoned veterans here that can help as well 😭
I'm not the best when it comes to coming up with solutions
Try this maybe
{
if (_target)
{
Debug.Log("Player found");
Vector3 direction = (_target.position - transform.position).normalized;
float angle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
Quaternion rotation = Quaternion.Euler(0, angle, 0);
_rigidbody.rotation = rotation;
moveDirection = direction;
}
}
private void FixedUpdate()
{
if (_target)
{
_rigidbody.velocity = new Vector3(moveDirection.x, moveDirection.y, moveDirection.z) * moveSpeed;
}
}``` trying to make an npc follow player. the npc does rotate but does not move
private void FixedUpdate()
{
if (_target)
{
_rigidbody.velocity = new Vector3(moveDirection.normalized.x, 0, moveDirection.normalized.z) * moveSpeed;
}
}
```Normalize your moveDirection
Oh damn
Sorry man I don't really know how to help witht his issue
I'll try think of something
Although I think some people here would notice the problem and help as well
Just not many active rn
How do you make the rotation radius smaller when using the RotateAround method?
Thanks
How do i make any gameobject instantiated from default tiles to save changes made to them during edit mode? I am able to instantiate gameobject using tiles in the tilemap and rotate them using "GetInstantiatedObject(position)" but when i go into play mode those changes are neglected, i think it is because it re-instatiates the gameobject and thus removes any changes made to it. I though of instantiating them using the prefab itself but i heard that it would be less performant, especially when dealing with a large amount of gameobjects which is the case. If more info is needed i can provide
Your claim at the end is incorrect. Use a prefab and read its position
If you need performance, make an object pooler
thank you for the help, i am not claiming, i am a little confused about how this works hence why i am having trouble, i also am having trouble finding more information about it to educate myself
HI! its possivel to set tag to image??
Can anybody help with me with making a random maze generation system, I could acomplish this, but I also need some random rooms placed in the maze, like maybe a office room, or a big courtyard. I just can't figure out how I would put it down in the maze, get rid of walls that are overlapping it, and connect it by doors. Can anybody please help?
ask exact questions
Ah, let me make it exact, how I would I place rooms in a maze without them overlapping?
So, I have a maze right, and I need to like slap down a courtyard in the middle, and of course that would overlap the maze walls, so how would I fix that?
i am not sure how object pooling would help me, i am trying to make a map using tilemap and tiles, the tiles are to instatiate the gameobjects by using their prefabs and then instantiating them with their right rotations, i am using only 5 tiles to do this, i am just having trouble making the rotation changes made to the instatiated gameobjects persist in play mode.
cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LogicScript : MonoBehaviour
{
public float playerScore;
public Text scoreText;
[ContextMenu("Increase Score")]
public void addScore()
{
playerScore = playerScore + 1;
scoreText.text = playerScore.ToString();
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PipeMoveScript : MonoBehaviour
{
public float speed;
public float deadzone = -70;
public LogicScript logic;
// Start is called before the first frame update
void Start()
{
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
}
// Update is called once per frame
void Update()
{
transform.position = transform.position + (Vector3.left * speed) * Time.deltaTime;
if (transform.position.x < deadzone)
{
Debug.Log ("Pipe Deleted");
Destroy(gameObject);
}
if (logic.addScore())
{
speed = speed + 0.2;
}
}
}
//I am getting 2 errors (cannot convert void to bool and cannot convert double to float) can someone help me fix this?
!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.
mb
if (logic.addScore()) i assume addScore() is a void type function
and you are using it like a bool function
it isnt working for some reason i've tried to fix it, it worked yesterday but it's not working today
it's required to have ide configured in order to get help here
Then pooling is not necessary. You brought up performance and instantiating many objects, so I brought it up
Just instantiate the prefab, cache the reference to the instance, and read the values from the instance
Vector3 startPos = new Vector3(transform.position);
Why do I get the 'Vector3' does not contain a constructor that takes 1 arguments error? Isn't transform.position a Vector3?
nvm, i am dumb
Vector3 startPos = transform.position; obv
I have a method that's being called on a Collision Trigger. Is it possible to stop the method from being played again while it's playing, even if there is another collision trigger?
Basically, I've got an enemy that can punch. The enemy will detect when the player is in front of them, but I don't want the player to be able to punch again when it is mid-punch
if(isPunching) return
Where would I place that?
you should have some bool determining if enemy is already being punched
or not
and only apply punch logic, if he isn't already punched
how do you instantiate something so that it doesnt become a child of the transform you want it to instantiate at
don't set the parent argument thne
but i need to so it spawns in at right pos
you can pass position as a parameter
public static Object Instantiate(Object original, Vector3 position, Quaternion rotation);
yea i did as an alternative instead of using tiles, because i really wanted it to work as tiles instead because everything else i coded using tiles and it would be an hassle to have to change things just for the gameobjects but if that is the case then i guess i will have to not use tiles or custom tiles for the gameobject instatiation and instead do the normal gameobject instatiation way using my custom brush.
ive done that but it still attaches to the transform
how did you do it
spawnedBullets.Add(Instantiate(bullet, new Vector3(spawnPos.position.x, spawnPos.position.y, spawnPos.position.z), Quaternion.Euler(0, 0, 180)));
it's not parenting anything there
so the parenting happens in other place
you can just do spawnPos.position btw
instead of breaking it to new Vector3(x,y,z)
how do i resize gameobjects to screen size? i have a static board which i draw on the tilemap but i wanted to make it playable for tablet and phone or do i need to make different games ?
this is a code related channel
Then use tiles, cache it, and read the values from it. I'm confused
so should i go to ui?
idk, not in code
if u dont know then dont say its the wrong channel
but it is the wrong channel, so wdym @tender hound
Good afternoon Fen. Quick question for you on these two pieces of code you have. Are you using the Player Input component and if so, are you setting the Behavior to Unity Events or C# Events. Thanks
it depends on how do you want to handle your input events
via unity events or c# events
Ok, so i paint the tiles using my custom brush, then i rotate the gameobjects that each gameobject tile instatiates during edit mode because it is way more efficient than having all the tiles orientations, but the rotations dont apply in play mode, it only works in edit mode. You keep telling me to cache it and read the value, in this situation where do i do that? In my custom brush?
In Unity2D, what would be the best way to create an punching animation? It's on a person that doesn't have arms, so just a floating hand, Rayman style
this is a code related channel
Ok, yeah I misunderstood what you were saying. I would ask in #🖼️┃2d-tools
Couldn't you do it via code?
@swift crag Based on other reading I'm doing as well, your code rather sounds like it was fit for Unity Events. The two pieces of code you provided seem to be two separate pieces of a jigsaw puzzle so I'm sure there's parts that don't link together or demonstrate how the event is fired was all so I figured I'd ask
Yeah, if you want to have the separate object move via code, you can
It's 1 sprite and it would be a hand flying towards and backwards from the player
i will try, i tried it before there and nobody answered, thanks anyways.
The fist is a seperate object to the body
so moving the object, not doing a animation like you said
My bad
i'd just use DOTween
Judging the message you're replying to, that would be no. InputActionReference would be the type of your class variable, that will appear in the script's Inspector. You can drag your Input Actions asset in it, and select a specific action
I would try to simplify the way you were asking, it was pretty confusing to me honestly
gotcha
in your Punch() method or whatever you have, just move the object that is supposed to be punched
DOLocalMove(endPosition, duration)
you can then assign stuff like
ty SPR2, so it's fit more for C# Events?
DOLocalMove(endPosition, duration).OnStart(() => isPunching = true).OnComplete(() => isPunching = false);
This is what my game is going to be like. The hands rotation follows the players position. Ignore the hand flying forward when it touched the player, it's not meant to be like that
Using an input action reference allows you to subscribe to the C# events yes.
Hmmm okay, I'll give it a go. Thank you
Yo guys is dotNET SDK 8.0 active?
Not for Unity
When I do this, the hand moves upwards, instead of towards the player
then your endPosition is wrong
Why not? Also, if not, what SDK environment should I use?
remember that's it's local position, not world
I created a SerializeField, put my player into it and then as my endPosition, I put player.transform.position
That is world position
Hmmmmmmm what exactly would be the difference?
And you are using local move function
Ooh okay
DOMove, DOLocalMove
Guys what the hell
It's just not supported. Unity uses the old Mono backend. Work is in progress to get it working with the Core CLR which modern .NET runs on.
If you're configuring your code editor, follow the guide.
If you're making a managed plugin (DLL), the documentation has instructions on how to create a compatiable one
I installed .NET SDK 6.0 but the folder didn't appear in the C:\Program Files (x86)\dotnet\shared\ folder
Only 5.0.something
Wait I'll try to repair the installation
InputActionReference fields do not need the PlayerInput component at all. However, the PlayerInput component does enable the action map for you, so it’s fine to keep it around.
Not sure how any of this will fix it. Unity does not use modern .NET
Oh, I was thinking about the wrong code.
You're stuck with .NET Framework 4.8 (max) or .NET Standard (2.x)
Ffs
Unity runs fine
I'm trying to reconfigure VSC
The example still was not using PlayerInput. It used the “Generate C# Class” class.
I'm getting this weird behaviour now. I'm guessing it's because the hand is parented to the body and when the body moves, it goes weird?
That should have been mentioned in the original post.
I’m doing errands right now so I’m not really here; you should ask me about this in #🖱️┃input-system later
I installed it through the link
A restart or logout/login is required to apply changes made by the installer
Once done, run dotnet --list-sdks in the command line to list installed versions
This is my directory of the .dotnet folder
Elaborate?
On the computer?
That's... pretty fucking stupid
I'm not saying your claim is stupid I'm saying the fact that I ahve to do that to install the SDK is stupid
You can go and manually set the PATH if you want
But the directory shows it's installed in the .dotnet folder
Or the restart does it automatically
.NET is not installed in your user folder
It's in C:\Program Files\dotnet\sdk
But using the command line to check is easier
I see them
noted, ty
Im confused? whats it is complaning about?
[SerializeField] private GameObject _heartPrefab;
[SerializeField] private GameObject _gemPrefab;
public int MaxHealth = 3;
public int CurrentHealth;
private readonly int _score = GameController.Instance.Score;
private int _scoreMemory = 0;
private void Start()
{
CurrentHealth = MaxHealth;
CreateHearts();
}```
is
private GameObject attack;
same as
private GameObject attack = default;
?
is
private readonly int _score =
correct?
Is GameController.Instance.Score creating a game object if it doesn't exist?
That's pretty much the only line that could cause the error
Yeah I moved it to a different place and now its fine
Show how GameController's Instance is made
private static GameController _instance;
private bool _isPaused;
public PlayerControls PlayerControls;
public int Score = 0;
void Start()
{
PlayerControls = new PlayerControls();
}
public static GameController Instance
{
get
{
if (_instance != null) return _instance;
var gameControllerObject = new GameObject("GameController");
_instance = gameControllerObject.AddComponent<GameController>();
DontDestroyOnLoad(gameControllerObject);
return _instance;
```
https://gdl.space/idawihiwec.cs i am a bit confussed why the npc chases me when the bool _canChase is false
That creates an object
new GameObject("GameController")
Unity doesn't like when you do that in a field declaration. Accessing GameManager.Instance runs the code in the get, which creates the object if that's not been done yet
Anything can be a microwave if you try hard enough
So the joke's on you
Because my laptop is already a microwave in on itself
Sure with enough voltage you can make anything emit pretty nasty EM waves
Wouldn't be very healthy though
But it's out of scope of this Unity server
For crying out loud
I already reinstalled
I checked the directory and it did in fact have the required SDKs
I'll try manually changing PATH
First command, yes
Check the first screenshot
Didn't output anything
Alright should work now
Let me check
I'm making progress
@short hazel Progress. It's a different error now :)
Kill me
@tough mortar Don't crosspost. DOTs questions belong in #1062393052863414313
@short hazel Why is the required dll missing?
Who knows? Did you check the first error about the nonexistent path?
what should i use to replace time.deltatime
why
why would you do that
there is no replacement for that
The first error is gone
_rigidbody.velocity = new Vector3(velocity.x, _rigidbody.velocity.y, velocity.z);``` what can i do about this the longer he chases me the faster he gets i want his speed to be constant to what i set moveSpeed too
Osteel
Interval in seconds between the last frame and the current frame
https://docs.unity3d.com/ScriptReference/Time-deltaTime.html
Unlike Time, which is just fixed
yes because you dont need it with rigidbodies since it already applies Physics update time
that was not a question, I asked the guy who asked it xd
i know what it is
so what should i take out from this code
* Time.deltaTime
Shit. My bad
also gpt script 
thx
ideally you want to only grab inputs in Update and carry over to FixedUpdate
would adding a ClampMagnitude be a good way to fix this
whatis moveDirection
you need to normalize moveDirection
sorry cat turn pc of 2 secs
should have got a case with power button on its side lol
{
if (_canChase)
{
Vector3 direction = (_target.position - transform.position).normalized;
float angle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
Quaternion rotation = Quaternion.Euler(0, angle, 0);
_rigidbody.rotation = rotation;
moveDirection = direction;
}
}
private void FixedUpdate()
{
if (_canChase)
{
Vector3 velocity = moveDirection * moveSpeed;
_rigidbody.velocity = new Vector3(velocity.x, _rigidbody.velocity.y, velocity.z);
SetAnimationState("Run");
}
else
{
_rigidbody.velocity = Vector3.zero;
SetAnimationState("Idle");
}
}```
they're unstoppable, one time my cat tipped a whole arizona ice tea can onto my desktop
funtime
I have c# but not omnisharp?
i normalized the rotation under update. do i need to also do it on the velocity?
You dont need omnisharp
You do for configuration
the direction
no you dont
how do i set a gameobjects velocity relative to its transform.right
You... need intellisense
Which comes from the Unity package + c# DevKIt
I use vsc
I get it
So what do I do
!vscode
make sure you did all the steps
Latest C# extension does not use Omnisharp anymore, it's based on the C# Language Server which comes with the extension itself
This one?
yup
Oh thank God
yh direction is normalized
I was about to have a panic attack
oh ok so is the speed fixed ?
no slowly speeds up over time.
C# Dev Kit doesn't work for me
wdym "doesn't work"
also shakes or vibrates as it runs which is weird
No Intellisense
can you make short vid
yes
you didn't do all the steps then
ok so install it
I installed .NET SDK 6.0, 7.0 and 8.0
ALl of them
Someone know how to do GetComponen but with ScriptableObject??
refresh Project Files then
so player speed is 8 and npc is 3 you can see that he slow creeps up and has some sort of vibrate issue aswell
this is runtime not sdk
Someone know how to do GetComponen but with ScriptableObject??
yeah its def shaking
A ScriptableObject is not a Component, so no. Use Resources.Load if you need to
You don't need to spam your question, you're not a child. SOs cannot have components.
Oh shit
thank!
you just need .net sdk 8
Such a simple mistake
https://gdl.space/oyafemaxer.cs full code an components
How
wait rotation is frozen?
did you try without Y rot frozen?
i think it might be fighting the code
also rigidbody should be rotate with MoveRotation/rb.Rotation/AddTorque
ok but you installed runtime
make sure it says SDK
restart PC after
Dude
למה אתה מתרגם את זה?
no idea what this is supposed to show
how do i fix this
That I have it installed
fix your IDE
byebye 😄
did you restart PC ?
type in dotnet inside terminal/command line
@frosty hound that's an insult btw, he called you a "motherf**er"
sorry for the ping
Do you want to correct that before I ban you or are you going to stick with it?
whats that sorry im knew?
Just... read the error
Your code editor, make sure its configured to highlight those simple syntax mistakes
!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
Also, for your proble, just type a semicolon ; at the end of the line
Classic syntax error
Anyways @rich adder just restarted my pc
dotnet seems to be working fine
Hey, I know that I can set the peramater in the animator by unisng functions like Animator.SetBool, but is there a way I can see if I that peramater is true or false if it is a boolean or saving a value within the peramater into another value?
GetBool()
yes and if you googled your seee it
thats not what I said
I corrected it
🇼 🇴 🇼
Great
why are you so childlish
I did but I couldn't find anything 🥲
thank you
Children tend to be childish
nothing is showing?
Yup
hmm are you sure SDK was installed
Because I have joy in life (:
You don't have to be so serious
!mute 981301314527035433 10d Instead of a ban, you get a mute.
hacking69 was muted.
Go into Unity External tools page and screenshot it
Elaborate
ima gonna make a thread so we dont flood
Very fair
VSCode Config
How to call on Trigger for 2d circle?
Also does it has OnTriggerEnter2D and OnTriggerExist2D?
why don't you consult the docs first before asking basic questions here?
what did you try
So far looked it up and not sure if it works with it.
Atm trying to understand how to make Box Collider only trigger on Layer with player
2D Sphere? Does such a thing even exist?
Circle?
Yeah tired atm
Its apparently the only one so this why I couldnt find specifically for circle
I'm pretty sure there aren't triggers for specific shapes bud
A trigger is a trigger
yup
as long as it matches the collider being either 2D or 3D
eg
OnTriggerEnter2D for 2D colliders set as trigger, obv
OnTriggerEnter is for 3D colliders set as trigger.
OnCollisionEnter2D and OnCollisionEnter are for 2D and 3D colliders that aren't triggers, respectively
Whats better trigger or collision enter?
they do different things
Are you trying to detect a trigger or a collider
Trigger is enough to make kill objects
I want something that detects player in some radius
Activly
Yeah I know that
thats the same thing
Trigger is enough to make kill objects
Both are enough..
Yeah Ive got the idea, on trigger then with raycast
how to trully determine if its better to use list of array
only you know that
Btw if I want real time transform data from different object, how should I do it? Just GameObject.Find?
i dont know what changes what
Or is there better way>
Noooooooo
i have option of making either 2 same arrays or 1 list
If I have a script to place an object to my cursor and a script when I click on an object to open a panel.
How can I get rid of the situation to open the panel when I place the object?
that makes no sense
one array just to determine size
Just add the object as transform to the other entity?
store the reference yes, preferably before playmode
Shouldnt scene load delete all object on previus scene?
If you need a collection that changes size, then the obvious choice would be a list.
yes but is changing size 1000 times wont be less optimal than just 2 arrays
📃 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.
static
static variables exist forever, shared between all instances
It doesn't matter how many Finish scripts you have on how many scenes, a static variable is created once and shared between everything forever
absolutely not
@polar acorn can you join a thread I need help configuring vsc but navarone is offline
don't use static unless you actually have a good reason why
!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
It has to be public to be accessed outside of the class
static is a completely different thing
not static
So reference the object properly
Tell it which Finish you want to change the levelCompleted of
You need to tell the code which Finish you want to access the value of
each one has its own copy of the variable
Back to my computer now. So if you don't mind me asking a few questions regarding Unity's new input system and Events
I'll start at the high-level then I can dig a little deeper to create a learning foundation.
When you add the new input system and add the Player Input component and decide at this point: Should I use Invoke Unity Events vs. Invoke C# Events in Behavior area (the attached picture). Is the choice basically "do you want to define the code and mapping of methods and events in the Unity Editor vs. directly in the code?"
What do you mean by "what type of reference"
You can either use Unity Events or get a reference to the player input via code and listen for those events
thx @queen adder but more or less that's what I said, right?
But... do you know what a Serialized reference is?
Well yes whats ur question? Sorry I prolly missed it
Those are many different ways to reference things
use whichever one fits your situation
Basically means you can assign private variables through the inspector
The question centers when you get to the Behavior drop down and is basically "do you want to define the code and mapping of methods and events in the Unity Editor vs. directly in the code?"
Yes it's up to you?
aka is your practice to drag and drop objects and work more in teh editor vs. directly mapping it in the code rather than the editor
Are you asking what most ppl use?
not necessarily what other people do but more direct about what that choice overall decides
getComponentInChildren will get component of parent object or not?
I want access to animator to change animation
Unity events use drag and drop via editor while the Invoke C# events will make you use code?
pretty much
I didnt actually need that cause I forgot the script Im working in is inside correct object
If ur looking for where the events are for "invoke unity events" click on events right under the Behavior option on Player Input
ty. yup, that's pretty much the area that I'll reference next. As I mentioned, I'm starting slow to build a solid foundation of knowledge on it while getting comfortable with syntax especially when it comes to Events.
So moving a little deeper...
So if a tutorial to implement some feature shows they were using Invoke Unity Events (and had the mapping setup in the editor in the area you mentioned) and let's say I preferred (for now particular reason) to keep in the C# Events as the behavior choice.....
public void Detected() => _triggeredByPlayer = !
_triggeredByPlayer;
Is there better way to flip true and false?
Are the basic steps to "convert" from Invoke Unity Events to C# Events to have a reference to the Input system (mine happens to be called InputActions and to have at least these three methods to translate it?
private InputActions _input;
private void OnEnable()
{
_input = new InputActions();
_input.Humanoid.Backpack.performed += HandleBackpack;
_input.Humanoid.Enable();
}
private void OnDisable()
{
_input.Humanoid.Backpack.performed -= HandleBackpack;
_input.Humanoid.Disable();
}
public void HandleBackpack(InputAction.CallbackContext context)
{
print(context.phase);
if (context.performed)
{
print("Attack performed");
}
}
me?
dont use print
Yes spring
use Debug.Log
It's the same thing
no its not
using UnityEngine;
using UnityEngine.InputSystem;
public class InputSystemController : MonoBehaviour
{
private InputActions _input;
private void OnEnable()
{
_input = new InputActions();
_input.Humanoid.Backpack.performed += HandleBackpack;
_input.Humanoid.Enable();
}
private void OnDisable()
{
_input.Humanoid.Backpack.performed -= HandleBackpack;
_input.Humanoid.Disable();
}
public void HandleBackpack(InputAction.CallbackContext context)
{
print(context.phase);
if (context.performed)
{
Debug.Log("Attack performed");
}
}
}
Yall be worried about such small details for no reason
it's not a small detail 😉
you don't have a call stack with print
just an empty console message
Oh OK thanks for the information 👍
but more or less those three methods are what it takes to convert from Invoke Unity Events vs. C# [and doing it yourself in code], right?
I normally get a reference to play input and get the input actions from that
I'm on my phone so I might type this wrong
mind giving me an example please?
I'm gonna code it give me one second
print literally just calls Debug.Log
PlayerInput playerInput = Getcomponent<>();
InputAction action = playerInput.Actions["ActionName"]
}```
They're identical
Documentation for the win!!
ow good to know
thought its pure c# method
didint know unity overrides it
The only difference is that print doesn't expose the second parameter of Debug.Log
print is a method on the MonoBehaviour class. it's not a "pure" c# thing
ok so if i have too many things of the same type collide with an object, it doesn't run its OnColliosnEnter method sometimes, what can I do to approach this?
Did that help? @warm anvil
so why did they split it into print and debug log
Incorrect
couldn't just keep one?
well it ignores that method at least somtimes
they just added print to the MonoBehaviour class for simplicity's sake probably. all it does is call Debug.Log. there's no "split" happening, it's just a convenience method for when you are working inside of a MonoBehaviour
or thats the explanation i can come up with
Then something else is probably the case
well there is an if statement in there that doesnt have Destroy() in it, but i check there is no way the condiotons are true, just in case i removed it now and ill try and see
allow me to ask a couple follow-up questions so it sinks in.
What I typically notice when people place a GetComponent in the Awake method is so they don't need to click-drag that component in the Editor. Is that what the first line is accomplishing?
PlayerInput playerInput = Getcomponent<>();
of course it is not as good as just using Debug.Log because you are restricted to the single parameter overload of Debug.Log that only prints a message and cannot provide context to the log
If so, not sure I've seen it in that specific syntax
it might not be typed to what I'm used to since you said you were on your phone
if im using a list of prefabs to spawn things in and using the number where an item is as there id how can i then later using a prefab that was spawned in know what id they have?
You have to reference PlayerInput
for (int i = 0; i<StatusList.Count; i++)
{
var go = Instantiate(BuffIcon, target.ui.BuffPanel.transform);
go.GetComponent<Image>().sprite = StatusList[i].SkillIcon;
}
Let's say I have 5 instances of those BuffIcons, right? What is the best way to remove exactly the one I need to remove?
Doing buffs system and well, basically displaying the buffs above the hero head, when certain buff expires, it's icon shall disappear from the buff display above the head.
As far as I understand, the method above doesn't actually keep track of the object it instantiated. So I guess I have to somehow mark / name / etc the instantiated thingie for it to be able to be targeted, right?
So, please, any efficient suggestions?
Store them in a dictionary, keyed by the int, then you can access that instance by that key
And yes that syntax is wrong
Same thing I just answered to someone else, add them to a dictionary as you spawn them, then you can find them by that key
PlayerInput playerInput = GetComponent<PlayerInput>();
embrace dictionary
what I figured, ty!
oh... wouldn't the dictionary be advanced coding already? 😄 I mean I have to enjoy learning the dictionary thing, but damm... I am not in mood right now 🙂 Any easier way please?
iterate
A dictionary is in no way advanced
uhh sorry im not to good at coding im not sure what that means or how i woudl do that
no dictionary is important
as a basic
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
the only shite is that Unity doesn't serialize them
you cannot view them in inspector without workarounds
How about this line you said:
InputAction action = playerInput.Actions["ActionName"]
Is the the purpose of that and does that potentially replace one of these three methods in my code?
private void OnEnable()
{
_input = new InputActions();
_input.Humanoid.Backpack.performed += HandleBackpack;
_input.Humanoid.Enable();
}
private void OnDisable()
{
_input.Humanoid.Backpack.performed -= HandleBackpack;
_input.Humanoid.Disable();
}
public void HandleBackpack(InputAction.CallbackContext context)
{
if (context.performed)
{
Debug.Log("Attack performed");
}
}
I've got this bit of code here which I'm using to get the enemy to punch the player. How can I get the enemies fist to return after being pushed into the player?
Right now, the enemy just pushes their fist into the player
where do you call the EnemyPunch?
well, you need a point where you decide to recall it
okaay... okayy... then going to get into that topic and will actually learn to do it 🙂 Thank you and @rich adder thank you too
you can use OnComplete() from dotween
In Update, but I have a bool that stops it from being called every frame
so it's called every 2 seconds instead
I'm at work spring
transform.DOMove(Player.transform.position, 1f)
.OnComplete( () =>
{
// return after completing
});
@west sonnet
no problem, I understand ofc
ok so i found the problem, its the hasNotInteracted = false;
originally, it is set to true, then once the fireball has interacted, it is set to false, this is so when its reflected, it cant hurt the player if they touch, the problem seems to be that the method is actually run too many times, cuz besides the reflection thing, this hasNotInteracted = false; was mainly a solution to a problem where a fireball (single) managed to do 2 damage instead oif one, which means it decrementet the hp twice, which could only happen if the method was run twice
But what code would I use to get it to return to it's original position?
store the initial position
then do the same you do, but to the original position
could use a curve too if you want fancy movement
var initialPosition = transform.position;
transform.DOMove(Player.transform.position, 1f)
.OnComplete(() =>
{
transform.DOMove(initialPosition, 1f)
});
you can also set different eases by .SetEase() etc
Someone else can prolly help u spring sorry @warm anvil
no need to apologize. ty for your help so far. have a great rest of the day!
Why does this not work?
Transform is a class. The concept of the Transform component does not have a position
individual object's transforms do
but if I did transform.position, wouldn't that give me the position of the gameobject the script is attached to?
any1?
the problem is some fireballs are dealing twice the amount of dmg unless i add hasNotInteracted which then leads to them not getting destroyed
Yes
yes, it's also the same object that is being moved
hi, how do I correctly make a list count condition?
I'm just trying to do this:
Debug.Log(keyframes.Count);
if (keyframes.Count > 1) Debug.Log("HUH");
but even though the keyframes.Count is 0, the condition is met for some reason :[
You can call position on any Transform you wish
Looks ok other than weird formatting and a suspicious lack of curly braces that would work for this contrived example but probably not your real code
If that "Huh" log is printed, then the count of keyframes is greater than 1
If I have an object with children, and I want those chidlren not to move when parent does.
Do I need to add Static Rigid Body to them?
That's what child objects do
Don't make them children
If you don't want them to move with the parent, they should not be child objects
yup, exactly what I think is supposed to happen, but apparently it doesn't work like that, the count is 0, but it still is printing the "huh" as if the count was greater than 1
If the code looks like that, it is utterly impossible for both 0 and "HUH" to come sequentially.
welp I guess it's my fault somewhere then, I'll check
Show the actual !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.
Hello, is it possible to make a switch statement of a vector? if so what could be a valid case?
guys i want to create 3D games but i have no knowledge about game dev. Should i start with 2D at first?
why
I'd at least recommend starting with 2D. There seems to be more youtube videos on covering the basics and then you can grow from there
okay thank you 😄
there is literally no reason to start with 2d if you only want to make 3d games. the programming concepts are the same and there are thousands of tutorials/courses for learning both
2D isn't "3D but easier" they're essentially the exact same thing
i thought it could be easier to start with
It's just different physics components and a different camera projection
so start with 3D?
Start with whatever you want
alright thanks!
2D assets harder than 3D
good to know haha
unless you like drawing frame by frame
nah thanks 😄
any1?
the problem is some fireballs are dealing twice the amount of dmg unless i add hasNotInteracted which then leads to them not getting destroyed
void MoveTowardsWaypoint()
{
var targetPosition = _wayPoints[_currentWayPoint].position;
transform.position = Vector2.MoveTowards(transform.position, targetPosition, _currentSpeed * Time.deltaTime);
}
Any idea why this is not moving an object towards position?
It looks like its working (looking like working at least)
Move destroy before check?
uhh wdym?
I mean is object getting destroyed when it deals dmg?
What calls MoveTowardsWaypoint
FixedUpdate
ye but sometimes does double dmg
why in FixedUpdate?
Show the full !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.
that's not the purpose of FixedUpdate
I might have gotten lost and added it therre
fixedupdate can work but you also multiply by deltatime in your step
so there's inconsistency
putting that in FixedUpdate is perfectly fine. it just runs on the FixedUpdate timestep instead of every single frame
yes and i believe this is not theirs desired goal
If I move while the enemy is mid-punch, it messes up the position of their fist and I can't figure out how to fix it. Can anyone help me please?
Time.deltaTime returns Time.fixedDeltaTime when called from FixedUpdate
Here's my code that handles the fist movement
it's auto converting
oh shoot that's pretty cool then
better to cache that 0.5f into a variable you can modify in the inspector
more designer friendly approach
You are also setting the position in Update.
how do i refernce a scene?
I use movetowards with fixedupdate for my own physics stuff
Whichever one runs last wins
i tried making a variable public Scene but it doesnt show in the inspector
Thanks, will do. Any ideas on how I could prevent the hand position getting messed?
You cannot reference a scene in the inspector
dang really
i have no idea what "gettin messed" means
so do i just have to make a new script each time i want a cutscene to do a different scene
I think issue is floatingmovement
The hand position is changed if I move when the enemy is mid-punch. It doesn't return back to it's initial position relative to the enemies body
becaues you are overriding the hand position somewhere else
and it's intefering the ongoing tween
pls 🥺
The hand is parented to a hand pivot. That hand pivot has a script that makes it's rotation follow the player position
That's the only thing I can think of
Or that the enemy is moving while punching
and so the hand returns to it's initial world position, instead of relative to the enemy's body (parent object)
cache its local position and use DOLocalMove instead of DOMove
How could I cache the local position?
the same way you do its world position but using the localPosition property instead
Hmmm that's not working because now the hand keeps thrust more and more backwards
show the !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.
i literally showd you this 1 hour ago with all code needed
because you are using DOLocalMove and you pass world position as endValue parameter
What's an endValue parameter?
Hello, I have a blend tree for my animations that contains the walk and run cycle of my character (among others), and how can I do a smooth transition between the animations when assigning a value to the blend tree (it directly switches from walk to run without transitioning as in the classic Animator) ?
Sorry
eh.. back to the first step
the first paraemeter you pass to DOMove/DOLocalMove
maybe some day we'll see their current code so we can actually point to the specific issue with it instead of trying to guess what they need to do/change
that's too easy
I'm using DOMove. The initial position I am doing locally, but the player (target) position, I am doing in world
is that correct?
no
if you use DOMove then operate entirely on world position
why do you mix it
initial pos as local, and target pos as world - big no no
either world or local, dont mix it
I see, THank you.
Is there a way to flip sprite without flipping axys?
rotate it or use one of the Flip<axis> properties on the SpriteRenderer
why do you ask such questions for couple of days now
you can google them all in 10 seconds
You have people here with almost 0 skills in C# asking basic questions. Me asking rarely something that I dont know if even exist wont kill you
sure, was just wondering
google first, ask second
I throw the question just incase I dont find it beforehand. At same time Im looking it up.
respect your and our time
and don't do it
you might find the answer, and in the meantime someone is writing you the answer on discord (and wasthing his time, because you already found the answer somewhere else)
This is an XY question
just put the renderer on a child object\
always separate your graphics from logic
You can then do whatever you want with it and it won't affect anything else
amount of rewrite I have to do omg
Rewriting code is a normal part of the development process
everything in the game typically gets rewritten 3-5 times before release
Issue is not borking it while moving logic
what's borking
Breaking everything cause you didnt think of needing to move logic
that's the part of learning
need to fix old code/architecture
in order to progress and make your life easier
Hello guys i have aproblem with the animation. In the follwing video you can see my character. After i run and stand still again the eyes of the character are bigger or just a litle different. But they are still animated. Anyone knows something to this?
Hello, i made a simple attack and I ran in to an issue when OnTriggerEnter2D was detecting collision for only once. when 'enemy' is already inside the collider OnTriggerEnter2D was not triggered unless enemy RE-entered players collider. I fixed it by switching RigidBody2D's sleep mode to Never Sleep. I do not understand the connection between these. can someone explain please?
if you want continuous collisional trigger callback then you use OnTriggerStay
this is a code related channel
Oh, sorry. Do you know where i can post this?
Not only the eye, but also other pixels are stretched as far as I can see. I may be wrong, but it's probably related to the camera, try adding Pixel Perfect Camera component, or search anything related to stretched pixels online. Also it's a code channel.
in a proper channel for animations
Thank you, i will try that
Okay
i want my sword to deal damage on click, not to take damage continiously while inside the collider
do you mind if i send you in DM a short screen video of what i am trying to tell you with my broken english?:D
If it's a one time thing I'd just use overlap circle
i'd recommend using a physics query like an overlapbox or something for that instead of relying on physics messages
otherwise may need to add your own cooldown inside of a trigger method
i just follow a tutorial. i do not have any idea of other things YET
how can i do that?
It worked, thank you very much
either a timer to compare against, or add a flag that resets everytime a attack is completed (you would store those that were hit inside of a list which you clear after every attack)
can you also tell me in example what does Sleep mode do for rigidbody2d?
no clue
you know you can just google it?
good fellow Xaxup. first rule of a programmer is to first google. so i did. i didnt found explanation uderstandable for my newbie gamdev brain so i decided to ask a good Mao to explain in a beginner section of this channel.
Stackovefrow solutions sometimes are just bad. There were many ocasions when reccomended solution or no longer works or is explained so bad that you are even more confused then before
true that. i rare use stackoverflow now. it has too many old solutions which doesnt work anymore
Any idea why this happens? Its only with right side. It gets stuck there sometimes.
void MoveTowardsWayPointAndWobble()
{
// Move towards the waypoint
var direction = _wayPoints[_currentWayPoint].position - transform.position;
transform.Translate(direction.normalized * _currentSpeed * Time.deltaTime);
// Set sprite flip based on direction
_sRenderer.flipX = Mathf.Sign(direction.x) > 0;
// All in the name of looks
// Fancy wobble
var newY = _initialPosition.y + Amplitude * Mathf.Sin(Frequency * Time.time);
transform.position = new Vector2(transform.position.x, newY);
}```
What does "this" mean?
And where was the log done?
bottom left
In code
We don't even know what code is logging that or what that distance has to do with anything
Thats distance to the point
what is the code being shown and how is it related?
It fees like it just loses all the speed
The distance of what to what point?
Thats movement
Perhaps the log is incorrect.
Its suposed to go from one point to another. I have transform of 2 points and it goes from one point to another
Hmmm... I think its getting stuck on something?
Perhaps the points aren't correct (working blind here)
what part exactly did you not understand from reading the Sleep() docs from rb2d?
Im just gonna leave that voodoo bug
ah, employing the ol Ostrich Algorithm
Isn't this the doc we care about? https://docs.unity3d.com/ScriptReference/Rigidbody2D-sleepMode.html
Im not exactly sure whats it complaining about
then check it?
any error might lead to several issues (even not related to your main issue)
That's an internal Unity editor bug
Hello, quick question. I have been studying C# on Unity for a while. I am not expert, I have been following a basic series of tutorials. At this point would suggest me try to build my own game by watching specific tutorials or just keep on learning with tutorials? (maybe just code?)
in many games when u get hit, there is a brief period where u are invincible, usually with lower opacity to the character and blinking, is that usually an animaiton? cuz like the player can still do all the other movements, which require animations, so cant be, or do ppl do it via a method that use IEnumerator and StartCoroutine that delay setting the opacity back and forth to create a blinking effect
Hey guys, do prefabs keep their serialized assigned objects? (when spawned in)
It seems like It doesn't in my game
they dont
which require animations, so cant be,
yes it can. you can have multiple animation layers that control different things
How do I connect them
animator override controller
u have to assing those objects to the spawner, then in the spawner use those objects to set the objects in the spawned object
things assigned to the serialized fields of a prefab will still be assigned. if they are getting unassigned then it sounds like something you are doing in code is unassigning them
oh damn
do you know of any visual examples or videos of this
can always start out with a simple game like platformer or flappy bird if you want to start getting into unity, but you should continue learning c# as you'll only get so far without it
Is it possible to have more than one OnTriggerEnter2D in a single script?
It doesn't let me add the camera in the searilized while in runtime
why would you need more than one?
Actually just thought about it, I don't think I would
prefabs and other assets cannot reference in-scene objects. pass the reference when it is instantiated
https://unity.huh.how/references/prefabs-referencing-components
I'm using a thing that's nested under the player, a camera, and spawning in the total player
then provide more details about what exactly you are doing and what exactly is happening that you are not expecting to happen
I am spawning in a network player, with a network object script under it, I have a camera that I need to activate and thus am using a script under the player, but when I spawn the charcter in the script fails to activate the camera likely due to the breaking of the seralized field
Does anyone know what this means? It appears when the player dies and the game is restarted
sounds like you aren't stopping the tween when the player is destroyed
see #854851968446365696 for what to include when asking for help. and as i've already described, serialized fields do not just "break" when you instantiate the object. it is likely something that you are doing in your code that breaks it.
also #archived-networking for networking related issues
it's dotween safe mode
handling the null for you
you are doing a tween on a null object
Is it an issue I should fix or is it safe to ignore?
Alright
it's better to fix it
do not ignore errors. fix it
I guess it's because the tween is one an enemy and the enemy is killed?
Wait no, the enemy isn't killed
How is the enemy becoming null when the game restartts?
how do you know its the enemy causing that error?
didn't i already answer this?
👍
Because the enemy is the only object that has tween on it?
okay, and how can i knew that?
and yet it is accessing the player's transform
Dont think this is beginner related, its prolly more like general level as i didnt find anything on google
I didn't mean that in a sarcastic way, I just didn't know if that was right was of using Tween
either way, if either object is destroyed you probably need to restart kill the tween
as in, in that sentece
I am not sure what I am doing wrong, but for some reason the ground check i have set up is not working, the hit variable is constantly zeroed out, causing IsGrounded() to always be false. Here is my script: https://hastebin.com/share/etelupecez.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
I am using a spherecast
I have a bool that turns to false when the enemy is killed. The bool prevents the tween from working
disable dotween's safe mode
then you will get normal unit null error reference
with call stack
does it stop the already running tween. or does it just prevent a new tween from starting
it prevents it from starting again
because the issue is that you are likely not stopping the tween when the object is destroyed
but are you killing the ongoing tween?
Yeah, I think so
show the code
yes so that doesnt mean
its killing the ongoing tween
you just prevent from starting a new one
you can cache the tween
in Tween yourTween;
it doesnt kill the tween
as i said multiple times
cache the tweens, and kill them in Destroy() method
How can I kill the tween?

Recently added this script: https://paste.mod.gg/pfubmnhrmpat/4
Arrow script: https://paste.mod.gg/dttndxjinjmu/5
Error i get (no clue what it means):
A tool for sharing your source code with the world!
A tool for sharing your source code with the world!
you do not have a tag called Arrow
oh might have forgotten to add it
Would I destroy the method that the tween is inside of?
that sentence does not make any sense
what do you mean by destroying the method
problem sovled, thanks
there is no such thing as destroying a method
You can only destroy objects, right?
In C# you can't destroy anything actually
you can only destroy UnityEngine.Objects
you should consider actually looking at the documentation for the asset you are using so we don't have to do it for you
can someone check this script and see if it makes sense tho: https://paste.mod.gg/pfubmnhrmpat/4
A tool for sharing your source code with the world!
that is a terrible idea to check things by name
i dont see anything wrong, but the method for fireball collision inst exactly doign anything
right off the bat i see you are basing logic on gameobject names which is a terrible idea
also that Update() method is unreadable
use tags or check for components. do not compare the name
break it into separate functions
Have you learned to use Debug.Log?
ill pinpoint where the error goes exactly... 1 moment..
Why do I not have the choice to "Build"?
because you have a different platform than the one your project is set to selected. also not a code question
ok so it doesnt go deeper than 3rd layer, and im sure that the condition for the 4th layer is true, since in the fireball script it is set to true as base value and is never hcanged there, only in this script at 5th layer
where should I ask for help
Debug the actual values
meaning it didnt assign Fireball fireball correctly?
well i already gave you the answer so you don't need to post your question in another channel. but for future reference you should use id:browse to find a relevant channel for your issue
thanks
I don't know how to set it to windows
the world may never know
OHHHHHHHH
🥵
I'm trying to add an object to a list on a specific index, how can I do it?, if I try to do e.g. myList.Insert(33, myObject) it gives me an error ArgumentOutOfRangeException: Index must be within the bounds of the List., am I doing it wrong, or does list not support doing it that way?
What you have is correct
the error tells you exactly where you went wrong
well you have to insert it at a position that actually exists in the list. otherwise you can just append it to the end of the list using Add
Also note the difference between inserting an element, adding an element, and setting an element.
okay, so I think this might be an xy problem, so I want to make a keyframes list, and I want to put them in a specific time, my idea was to set the keyframes' index to the exact time so I could get "current and next" keyframes easily (just count from lower to higher index), so I'll instead ask, is there a better way, any documentation or something similar I can use/read or do?
https://gdl.space/azavodopun.cs hi can some one please have a look and tell me if im using states correctly. Any just before i attack i get some animation flickering
use an array instead of a list and set the array size to the number of keyframes
I'm trying to make a prefab of my enemy but when I do, the references in my scripts don't apply.
references to other objects
Is this not possible?
assets like prefabs cannot reference in-scene objects. pass the reference when the object is instantiated https://unity.huh.how/references/prefabs-referencing-components
I haven't really ever used arrays, so how can I add values to the array "in runtime"?, I know I can set them on the declaration but I don't know how to set them somewhere else :[
array[index] = value
alr alr, tysm
use List<>
if you want to dynamically manipulate the size
you cannot add values to array in runtime
the array has fixed size
you can modify the existing indexes
you are missing his point completely
any one have a few moments please
I have a problem, when i import my prefab to my project it appears that error but when i import for another project, it doenst have errors
isnt really doing its job as a condition...
this script is attached to a player, the shield is a child of the parent player, so idk how to detect a collision between specifically the fireball and the shield..
remember how it was suggested to use tags or components rather than gameobject names?
also note that the collision.gameObject cannot both be a fireball and a shield if those are completely separate objects
well im only gonna have one shield
also i see the problem
im checking if the fireball is the shield, rather than if they are colliding
i have this script in another one and i forgot to chaneg that part, but then... how DO i check if they collided wit heach other?
in the shield you can check if it collided with a fireball. in the fireball you can check if it collided with a shield
you don't need to check both in each
is there any way I can define some bounds without creating a collider?
Define "bounds"?
what kind of functionality would these "bounds" have?
shame that its not possible to do it in the collision script but id have to go to the fireball,although i suppose it makes sense cuz id need to use the OnCollision method
thanks tho
its just so that I can do certain calculations on it like getting the closest point from a position
hey peeps. i've got a game object with a line renderer + physics2d raycast thats facing transform.right, but im having trouble successfully rotating the object on a 2d plane to line up with another specific game object, in this instance, the player character. i'm not well versed in quaternion stuff. full code for the spawned game object is here https://hatebin.com/iosfkcnugy Now, i could clamp the x and y rotation axis I believe but this doesnt seem elegant or and is more of a band aid solution. I do have some alternative code i've written for a different demo that faces the target object but it does so without a delayed rotation which is what im after.
i could just drop a collider in the scene and remove all of the collision layers on it to do the same thing, but is there a better way to handle this?
Well, there's the Bounds struct. Not sure if it has whatever you look for though.
Cause it sounds like you want an actual collider.
hmm, its only purpose would be for me to just fetch the closest point from another position
i wouldnt be using the collision detection or anything like that
Bounds seem to have a method for getting the closet point.
You can't rotate it in space though
ohhh, hmm thats def a limitation
dam its still not rly working
cuz i set it true in OnCollision
and i check if its true in another OnCollision
ehh, i could just use a collider i guess
where do i go from there?
What're you trying to accomplish?
Not entirely sure what you're trying to achieve.