#💻┃code-beginner
1 messages · Page 116 of 1
what's wrong?
Is there a setting I can enable that allows objects to pass through eacchother but still register contacts?
use Trigger colliders
yes
but you still need a rigidbody for that to work right?
yes
so how do I make the rigi body pass through objects while still registering collisions?
If the collider is marked as Trigger. It will register Trigger events but will not obstruct movement of the rigidbody
Scroll up and remove the namespace you unnecessarily added
thanks
FIXED
I have problems with the Camera, its stuttering and lagging, I dont know from where this comes, this prototype is an early development stage so there arent many scripts that could cause that stuttering and I'm moving the Camera in Late Update
private void Start()
{
isGameActive = true; // change later
Cursor.lockState = CursorLockMode.Locked;
}
private void LateUpdate()
{
if(isGameActive)
{
moveCameraOnMovement();
}
}
private void moveCameraOnMovement()
{
currentX += Input.GetAxis("Mouse X") * sensitivity * Time.deltaTime;
currentY += Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
currentY = Mathf.Clamp(currentY, YMin, YMax);
Vector3 Direction = new Vector3(0, 0, -distance);
Quaternion rotation = Quaternion.Euler(-currentY, currentX, 0);
transform.position = playertransform.position + rotation * Direction;
transform.LookAt(playertransform.position);
}
playertransform is the transform component of the player seen in the video
if i add a script component to an item, does it trigger the "start" function when it gets added?
If your camera follows the player(parented to it) it's most likely that the player movement is jittery. One common cause is lack of interpolation on the rb(or breaking it due to incorrect movement/rotation)
Its not parented and the camera movement is jittery even when the player stands still watch the vid
Yes, it should.
Can't watch it on mobile. Download speed is limited.
Maybe when I get home.
public void Start()
{
// Reference to this object
myObject = gameObject;
// Reference to the EnemyAI component attached to this object
enemyAI = myObject.GetComponent<EnemyAI>();
// Load the VFX prefab from resources
vfx = Resources.Load<GameObject>("Starburn");
// Load the required stats from resources
haste = Resources.Load<Stat>("Haste");
power = Resources.Load<Stat>("Power");
mana = Resources.Load<LimitedStat>("Mana");
// Set initial stats based on loaded values
tickFrequency = 1 - haste.GetAmount() / 2000f;
damage = 1 + power.GetAmount() * 0.1f;
duration = baseDuration;
// Instantiate VFX and set its parent to this object
vfxInstance = Instantiate(vfx);
vfxInstance.transform.SetParent(transform);
// Start the Activate coroutine
StartCoroutine(Activate());
}```
Oh cause its gets attached but it doesn't seem to get the needed things
Well, start from confirming that it is called indeed. Add a log or a breakpoint.
@merry spade try commenting out the LookAt line for a moment and test, I've found that sometimes LookAt causes the camera to 'flip' and produce undesirable results.
its still flipping
should I send a video of it?
yep, just confirmed it, it gets called
but it doesn't take the needed things
Then you'll need to provide more info on the actual issue.
well it does take the enemy ai aswell, but it doesn;t take the the scriptable objects stats nor the prefab so the issue seems to be on the "resources.Load" rows
screenshot your project view of the So's
right, so why would you expect Resources.Load to work when you are not using the correct folder structure?
oh, tought it would find them by name, do i need to give it the path?
you need to go and read the documentation
The first line of the docs.
thank you guys!
uhmmm it seems to be working now with the prefab but not the SO's
i tried like this mana = Resources.Load<LimitedStat>("ScriptableObjects/Stats/Mana.asset");
and this
mana = Resources.Load<LimitedStat>("ScriptableObjects/Stats/Mana");
fixed it
just had to use the player prefab and its statmanager component instead
Anyone have the right component values for drifting wheel colliders?
If I have a reference to another GameObject's button like this inside another object's script, can I get access to the button's on click function and add functionality within this script?
button1.AddListener
I couldn't do this but it seems like something like this will work?
button1.onClick.AddListener(HandleButtonClick);
should do
hello, how do i make the program give me suggestion so i don't need to write the entire line (im using visual studio code)
!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
any tutorial on how to make an item system like one in binding of isaac / slay the spire artifact that uniquely affect the gameplay? i dont know if i should use scriptable object for this cuz the item should be different in the functionality. well except sprite/description
I would use SOs personally
I want to but idk how it gonna work using it. Like having each script for each item and make a single instance of it?
Thought the intended use of SOs is to create multiple instances of it
But each item gonna have a whole different function that change different aspects of the game
which one should i download for visual studio?
Just install it through Unity Hub, it'll auto configure it as well.
The one you have license for. But what Osteel said.
alright.
That is the intent yes. You would create an SO asset for each artifact that has all its general info and whatever flags you want to change how the game is played.
For example, in BoI, an item SO would have a property for how it affects the movement speed.
thought of that but when create instance of each item im gonna have a list of check list too choose what item it suppose to be . feel lil wrong lol
thank very much
When you have a collision, can you measure the speed of the collision with oncollisionenter?
does some1 has a link to a tut where u can make a good ai i made a few but there just ret..d
collision.relativeVelocity is the speed
Is that the speed at which they collided?
Relative to what?
to each other
is there a way to serialize a 2 dimensional array so it can be edited in the inspector?
Not unless you make a custom inspector. But how do you imagine it? That would be a huge ass grid.
Not very convenient to edit
any ideas why on earth start wave isnt being called?
handle picked up is called
i put a print in there so i know it is
sort of just how a normal serialized array would look in the inspector but with 2 columns
That wouldn't be 2d array then.
how so?
Any errros?
Well, unless it's 2x2
nope
Which you can just have 2 vectors for. Or a matrix
yeah, 2 wide, and just expand dwon is how I woudl imagine it
DO u know whats the ? point of that question mark
could that be causing an issue
That would be super inconvenient to edit.
It's checking if anything is subscribed. Does it error without it?
if you only have two columns you can make your own class:
[System.Serializable]
public class MyData
{
public int x;
public int y;
}```
And then have an array of MyData
idk havent tried i iwll check
Maybe there's a better way to do what you want. Can you explain a bit what the use case is?
can you show where you defined OnPickUp?
then just make a new array like this: public MyData[] data; ?
it errors and says this
sure
Then you probably don't have anything subscribed to it. Can you share the whole code properly?
!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.
so I'm making a semi rhythm based game that includes flying and I want to be able to control at what time and speed the velocity changes with 1 array
it works with 2 but i just thought a 2d array would be a better way
if this bit of code not subbing to the event?
I see. Then what Gruhlum recommended is probably a better solution.
It is, but are you sure that's the same instance?
hmm i set the instance during start
Ok, thank you
I thought you can only subscribe to events from within the class that defines it 🤔
OnEnable() is called first
Instance of pickup. Accessing your singleton instance would throw a null before the assignment to the event
Maybe share the whole script. As there are a few things unclear.
tbh if i never set instance then shouldnt it have thrown an error?
i wil change to awake and see if that helps
Awake and OnEnable are called at the same time I think, so it's 'rng' which one will run first
whats called after start
i realized i set onpickup to null during start
so on enable i add an action to on pick up
but when starts called, it wipes that out
yep alr thanks
i fixed it now
just be careful, the order of scripts can change when you build the game.
That's why you share the whole code...
Ah, so what comes after start
Update 😛
nothing comes after Start, you should use Awake() for setting up everything on itself and Start() for setting up things with other objects. If you need more control you can have 1 script that calls those setups one after another:
void Start()
{
manager1.Setup();
controller.Setup();
player.Setup();
}```
does some1 have a idea how i can make a seprate inventory for every player i am using netcode
alr thanks
using System.Collections.Generic;
using UnityEngine;
public class jumpanim : MonoBehaviour
{
// Start is called before the first frame update
public Animation jumpanimation;
public AnimationClip jump1;
public AnimationClip jump2;
public float timer;
public float animno;
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space)) { jumpanimation.Play(); }
if (Input.GetKeyDown(KeyCode.Space) && jumpanimation.isPlaying)
{
jumpanimation.Stop();
{
if (timer < animno)
{ timer = timer + Time.deltaTime; }
else
{
jumpanimation.clip = jump1;
jumpanimation.Play();
jumpanimation.clip = jump2;
}
}
}
if (jumpanimation.clip == jump1) { Debug.Log("anim2 playing"); }
}
}
SOMEONE HELP why no anim playing but still no error
im rly rly new to coding
someone an fix it for me
Figure out how you want to represent your items and one over the network. Once that is figured out, figure out some collection on a component and sort out how to sync that over the network. You can ask for more details in #archived-networking.
thx
It's not RNG, Awake always happens before OnEnable.
https://docs.unity3d.com/Manual/ExecutionOrder.html
it does, but it goes more like this:
obj 1 -> Awake -> OnEnable
obj 2 -> Awake -> OnEnable
so if you read values from another object in OnEnable the Awake() method of the other object might now have been called yet.
yes, the two methods are called in sequence
Ey, a quicky here; is there a way of like, make the player input on keyboard axis to be more smooth, and not just go almost instantly to 0 to 1?
no thats for u to work out, the input axis just shows player direction
Lerp some value based on the keyboard input, don't rely on the actual raw input being smooth
consider Mathf.MoveTowards / Vector2.MoveTowards
use Animation curve for acceleration
Vector2 from = Vector2.zero; // [0, 0]
Vector2 to = Vector2.right; // [1, 0]
Vector3 smooth = Vector2.MoveTowards(from, to, 0.1f); // [0.1, 0]
Hello, I am using 2023.2.3f1. when I selected gameobject in hierarchy, it reset serializefield enum property in the component. is this a bugs?
current = Vector2.MoveTowards(current, input, Time.deltaTime);
this will move current towards input at a maximum rate of one unit per second
I haven't observed this. Can you show your code and the inspector?
Although, I guess I am on 2023.2.2f1, not 2023.2.3f1 😛
I notice this is happen if I selected multiple gameobject in hierarcy, then all enum property I've set, back to default.
Do you have any custom editor code?
No
That sounds like incorrect multi-object editing behavior
im trying to make a dialog system for my roguelite, somethng like hades where when you enter a room event characters talk. i made a list of dialogs objects and i plan to get one dialgo randmly based on what characters are on the event. im having troube to find a way to filter my list of dilogs. like: "I want a dialog with character X and Y "
can i create a copy of a scriptable object so i can modify it without effect the original?
You'll need to store all of that data along with each chunk of dialogue
Yes. Instantiating any Unity object will create a copy of it
like this ?
Maybe you'll have a dialogue set object like this:
public class DialogueSet : ScriptableObject {
public List<DialogueLine> lines;
public List<Character> characters;
}
then you could filter all of your dialogue sets
dialogueSets.Where(set => set.characters.Contains(theDude));
(this is using LINQ)
all my dialogs are in a "DialogLibrary" prefab, when i make a new dialog i add it as a child of this prefab
Yes -- modifying weaponatt will not modify the object that weapon refers to
same deal; you'll want to get a list of all of the possible dialogue options, then filter them
not wokin ;w; modify weaponatt will modify weapon instead
its not affect weaponatt by anymean
thats kinda what im doing
foreach (Transform childItem in dialogLibrary.transform) {
AllDialogsInLibrary.Add(childItem.GetComponent<dialogController>());
}
just the filter im trying to solve
well, you'd better put some more information in dialogController
AllDialogsInLibrary.Where(controller => controller.characters.Contains(theDude)) will give you a sequence of every dialog controller where its characters list includes theDude
I recommend to instead use 2 classes, 'WeaponDataSO' and 'Weapon'.
'WeaponDataSO' only exist to hold the default values while Weapon is a serialized class that loads the values from the SO but has it's own, allowing you to change them without affected the others.
That sounds like a better idea, yes.
Weapon can also reference WeaponDataSO, and just store changes to that base data
public class Weapon {
public WeaponDataSO definition;
public int upgradeCount;
public float Damage => definition.damage * (1 + upgradeCount * 0.2f);
}
Each upgrade adds 20% more damage
this is the weapon class
Steps to reproduce: 1. Open the attached user's project "MultiSelectIssue.zip" 2. Open "Scenes/SampleScene.unity" 3. Select both Enu...
hm, but it shouldn't be happening in 2023.2.3f1
the bug was reproduced in several editor versions
but it was fixed in 2023.2.0b17, which ought to mean it's not in 2023.2.3f1
It says fixed in 2023.2.0b17, but the bug still happen in 2023.2.3f1
its literally what im doing rn. but idk how to copy data from the so into a new WeaponDataSO to use it inside weapon class
modify the copy seem to only effect the SOs object instead of instance created in weapon class
that is not what you're doing right now
Gruhlum suggested using two separate classes
also, you still haven't shown me your code, so I don't know what you're doing
📃 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.
#💻┃code-beginner message like so
this shouldn't happen
although it should be
[System.Serialize]
public class Weapon {
oops
keyword moment
there we go
you want to separate the definition from the runtime data
Do you already have something assigned to the weaponatt field?
You're instantiating weapon in the Start method of WeaponHandle
and getting weaponatt in the Start method of weaponattributeHandler
If the second Start starts first, it'll run before you instantiate the SO in the first Start method.
and it'll get whatever was serialized in the weaponatt field
I would strongly suggest just doing this -- it'll prevent this problem from happening in the first place.
It's also how I've done exactly this in the past (:
i made a game for a jam with mostly-procedurally-generated weapons
the base data for a weapon lived in a ScriptableObject, and then the upgrades were tracked separately
ah i see the problem now. i mistake the object assign in weaponatt is the clone and yes after that fix it seem that weaponattributehandler run first and return null here
so create a class inside weaponhandler called weapon and assign SO then create an instant of weapon class?
or maybe WeaponData or WeaponConfig
it worked very well, now i can add more filter layers, thx for the help
I see two options:
WeaponMonoBehaviour that references aWeaponBaseScriptableObject and holds all of the upgrade dataWeaponMonoBehaviour that references aWeaponConfigobject, which holds the upgrade data.WeaponConfigreferences aWeaponBaseScriptableObject
The latter would make it easy to save and load weapons
just make WeaponConfig serializable
Weapon would need a method to build the weapon's visuals and reset stuff
which you'd call after installing a new WeaponConfig
when you say Weapon class you mean Weaponhandler or create new script called Weapon?
The class you've called Weaponhandler, yes
If it represents a weapon, name it Weapon
(also, you should PascalCase your class names)
WeaponHandler, WeaponExplosionWidget, etc.
yeah i know ;w; i should start doing that from now
thank you much Fen
thats very helpful
ill try to explain my problem the best i can
in a function, i have an object that i want to move smoothly to another position. the problem is that it isnt in the update function and the function runs when i press a button. ive tried my best to research but due to my lack of skills in explaining, i cant find anything.
You need to set a field when you push the button
then, in Update, move the object if the field is set
so like, a bool?
yeah
i was thinking of that but it just seems so... how do i say this. unpractical???
private bool moving = false;
[SerializeField] Transform moveMe;
[SerializeField] Vector3 destination;
void Update() {
if (moving) {
moveMe.position = Vector3.MoveTowards(moveMe.position, destination, 10 * Time.deltaTime);
}
}
public void StartMoving() {
moving = true;
}
i mean, how else would you do it?
you need to do something over the course of several frames
so you need to remember something from frame to frame
You could also use a coroutine, which lets you write code that suspends and resumes
or use a library like DOTween that does roughly the same thing
i hate spaghetti code and this seemed unpractical for me, so i avoided it (man i am stupid)
but thanks for telling me its fine to use it
i even hesitated to put it in code-general because of it
"spaghetti code" happens when you have lots of weird dependencies
like if this class had 15 different moving variables and 6 destinations
and some of the variables affected each other
alrightie
well thanks again and sorry in advance
for... being a burden???? its such a simple answer, i think i just overthink too much
thanks a lot man God Bless and Merry late Christmas
is the fix also gonna get backported to 2022 LTS?
that's what the bug report says, yes
fixed in 2022.3.14f1
It's possible that there was a regression in 2023.2.3f1
I can check that later
using UnityEngine;
using UnityEngine.UI;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 20;
int boardMoveSpeed;
bool onBoard;
public GameObject mainPlayerObject;
public Rigidbody2D mainRigidbody;
private void Start()
{
}
private void Update()
{
CameraRotation();
PlayerMove();
}
void CameraRotation()
{
Vector3 mousePos = Input.mousePosition; //get mouse position
Vector3 objectPos = Camera.main.WorldToScreenPoint(transform.position); //change to world space
mousePos.x = mousePos.x - objectPos.x; //Use trig and differences to find the angle to the mouse
mousePos.y = mousePos.y - objectPos.y;
float angle = Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg; //remember to convert to degrees
mainPlayerObject.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle)); //set rotation
}
void PlayerMove()
{
float x = Input.GetAxisRaw("Horizontal");
float y = Input.GetAxisRaw("Vertical");
Vector2 force = new Vector2(x * moveSpeed, y * moveSpeed);
mainRigidbody.AddForce(mainRigidbody.transform.forward * force);
}
}
Hi everyone I have this script and I want the player to move in the direction that they are facing
however I can't seem to get it working
In the player move function I have managed to get the x and y inputs no problem but when I try to implimnent the force with a direction the player doesnt even move at all? any thoughts?
how do you know you've gotten the x and y inputscorrectly?
using debug.log
okay, good
I still get 1, -1, 0 ect
You're modifying the rotation of the player transform directly whilst also trying to use a rigidbody
this can cause problems: you're fighting the rigidbody
So I should be rotating the rigidbody?
i would suggest setting mainRigidbody.rotation instead
ahhh
also, that's a pretty weak force
well, sorta
one thing to check: look at the inspector for this component
make sure that moveSpeed is 20, not 0
yes I've done that, I came across that earlier. Ill try test this
that would've happened if you added the initializer after attaching the component
unity will remember all of the values in the inspector
so if you started without an initializer, the default value would've been 0
I see. I've changed the playerObj to the rigidbody rotation now too. Still no luck.
the other thing is that I don't really understand mainRigidbody.transform.forward * force
can you even multiply a Vector3 and a Vector2 like that?
oh, you can!
apparently so. I wanted to add a force in the direction the player was facing
it's just promoting the Vector2 to a Vector3
then multiplies each pair of elements together
That is not what you want
You want to do this:
transform.TransformVector(force);
okay lay it on me
This converts a vector from local space to world space
If the object isn't rotated or scaled, this will do nothing
If it's rotated, the resulting vector will also be rotated
okay so in the add force it would be mainRigidbofy.transform.forward * TransformVector(force)?
no, just transform.TransformVector(force)
Multiplying the vectors isn't meaningful here
[a, b] * [c, d] is [a*c, b*d]
Ohhhhh!
also, transform.TransformDirection is probably more correct
that would be the forces multiplying would make the force 0
that doesn't care about scale
If you use TransformVector, scaling up your player will make you move faster
To see what this means, try selecting your player in the scene view
Make sure the scene view is set to "Pivot" and "Local" modes
and press W so that you see the arrow handles
The arrows show you the local axes of the selected object
Press X to switch to Global mode. The arrows are now world-space directions
alright perfect, but for some reason my w a s d is no reversed? A and D are doing forward and backward and vise versa. I can see the arrows now too which is good
transform.TransformDirection(Vector3.forward) will give you an vector pointing in the blue arrow's direction
Look at the arrows when you're in Local mode
red -- X -- right
green -- Y -- up
blue -- Z -- forward
in 2D games, the Z axis usually points into the screen
so your two arrows will be red and green
If you move in the positive X direction in local space, you move along the red arrow
and if you move in the positive Y direction in local space, you move along the green arrow
yes I understand
So you might need to adjust how your character's graphic is rotated
if the character faces in the local +X direction, holding W will appear to make you strafe left
OHHHHHH!
in 3D, it's obvious -- the character should face forward
I guess people usually make a 2D character face upwards
like so, where the little cube is the direction you appear to be facing
If you set your character up like this, holding W still makes you move along the green arrow
so it'll look wrong
Thanks so much for ur help
basically like a full crash course on forces and charatcers lol
no prob (:
getting a good handle on your axes is really helpful
i don't have to guess-and-check very often
(except when trying to attach a gun to a character's hand. i always do that wrongly)
too many links 
https://unity.huh.how/physics-messages is great for physics stuff -- there're several ways that can go wrong
I used to struggle to get collisions and triggers working on the first try
I remeber a while back when I first touches on physics in 3D and my mind was blown with how much stuff there was which is why I've shifted into 2D for the time being.
(In Awake())
_actions.Drone.Yaw.performed += OnYaw;
...
(called in Fixed Update)
private void Rotate()
{
// Adjust rotation based on input
float rotationAmount = _rotationInput * _rotationSpeed * Time.fixedDeltaTime;
Quaternion deltaRotation = Quaternion.Euler(Vector3.up * rotationAmount);
_rigidbody.MoveRotation(_rigidbody.rotation * deltaRotation);
}
...
public void OnYaw(InputAction.CallbackContext value)
{
_rotationInput = value.ReadValue<float>();
Debug.Log($"Yaw: {_rotationInput}");
}
...
Using this setup my character object keeps spinning when I stop making new inputs. Shouldnt the Input system send 0.0 in the value at that point?
Not using a player input component.
if you are only subscribing to the performed event then it won't call OnYaw when you cancel the input (release the keys)
subscribe to the canceled event too
Ill try that.
I find it can be cleaner simply to read the value in Update rather than using events for this kind of input handling
This is continuous input
Still spinning.
hi
when i put in my dmg overlay variable, it says "type mismatch"
here is my code
wait
!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.
either you are not dragging an Image component in, or you are trying to drag something from the scene in, which you cannot do because assets (like ScriptableObjects) cannot reference scene objects
https://unity.huh.how/references/prefabs-referencing-components
you cant drag scene objects there
ahh
is it logging when you release the key(s)?
well
use prefab
prefab?
makes sense
Its not logging 0, its always the last input I did.
thanks
goodluck 🙂
did you make sure to save your code and it compiled after you added the subscription to the canceled event?
does anybody know how to change the amount of times per second that fixedUpdate is updated?
projectsettings
its in the physics section
It did recompile. Just made sure again.
is there a way to do it on a script by script basis
why
i'm trying to make a rhythm game
then show your code using a bin site
sounds like poor design
Will do.
wym
why are you changing the physics step in the first place?
and why you want it different for each script
you can also just make your own version of fixed update/ updates anyway
because if I have it set to 60 instead of 50, it'll make it way easier to subdivide seconds
you can?
idk how to do that unfortunately
yeah
i mean there's a reason i'm in the beginner channel
the extent of my knowledge is a basic understanding of C#
just change it to 60 if you want 60
so i made a new prefab and stored my image object from the scene into the asset
and then used said asset for the inspector's parameters
sorry I think its in Time
iirc you can also change the Physics update rate to Update loop instead of FixedUpdate
at your own risk on that though
What’s the difference?
however when i interact with the death cube (which calls the set health function) my damage overlay stays invisible
you've commented out the subscription to the canceled event so it won't work
color doesnt go to 255
that would be 32 bit color
Color is 0-1
Color32 0-255
Sh*t, yeah I dont know why I uncommented .started but not .cancelled based on what you wrote initially. 
Works now.
Now Ill have to fix the Move() and Elevation().
Thank you @slender nymph.
here is my new code for reference
why are you increasing by a specific number like that rather than a number multiplied by deltaTime? or do you not care that those with higher framerates will increase the Health variable faster?
guys how do i fetch the sprite needed for a reference in my script?
like normally i would just drag it into the reference slot in my gameobject but it's a prefab
are you trying to reference something inside the scene from a prefab?
i'm trying to reference a sprite that's in my sprites folder
is the script running ? what is the value of the one in Update
you can reference prefabs no problem
then why can you not drag it into the inspector?
note the difference between a Sprite and a SpriteRenderer though
what is this "one"
oh
ahhh the update doesnt run
but the function does
because this script is not embedded in any object
idk where i'd put it though
If this is a MOnoBehaviour then it can ONLY exist on an object
if it's not a MonoBehaviour then it can't b e attached to an object
well this is a new conundrum
not really
if you need something to run every frame
put a monobehaviour on a GmaeObject in the scene
with Update
it can call a function on some other object if needed
can we put behaviour in particals in a particale system?
No
only "behavior" they have they can send collision messages
reading some decompiled code. what does int num = this.armed ? 2000 : 30; mean
armed is a bool
ternary operator
if its armed then num is 2000
its just a fancy if else
the name is a bit silly
"ternary operator" means it operates on 3 things
like how "binary operator" means it operates on 2 things
it's like calling + the binary operator or ! the unary operator
what is Object.op_Equality and Object.op_Inequality?
I'm seeing it in some netcode parts here and I'm not sure what it does.
word of advice : dont decompile code when you don't know the language its written in
also this isn't the place
That's a rude way to refuse to answer.
It's just the equality operator and inequality operator. You should try
first always
And the person above is right, this isnt the place. #📖┃code-of-conduct even says dont discuss modding or decompiling
Looking at decompiled code will be mostly useless for your learning as well
use a string variable
Make the string public or [SerializeField] then change it in inspector. Public if you want another script to change it
im making an multiplayer game and the player needs to instantiate something onto itself but the client cant do that so i need a funktion that gets called when a player joins and get his gameobject
ServerRPC
In Unity, you typically create a new game object using the Instantiate function. Creating a game object with Instantiate will only create that object on the local machine. Spawning in Netcode for GameObjects (Netcode) means to instantiate and/or spawn the object that is synchronized between all clients by the server.
thx
What size does a "private GameObject[] enemies" have?
whatever you assign to it when you create the array
right now its null 🙂
thanks
@rich adder"Arrays have a fixed size that is set when they are created, while lists can grow or shrink dynamically as items are added or removed."
once you make the array, you cant change the size anymore, that's all there is to it. Unlike list where you can just add stuffs later
this is correct. but the default value of any reference type variable is null until it has been assigned an object that is not null. and at that point you are assigning a fixed size array
does anyone know how to write a script that stores the time elapsed in seconds?
have you googled it?
yes
im going to ask this again. https://youtu.be/qQDM8AX8mOY?si=pTV4qSjosPmtMG5H how do i make something like this? the exact same thing. no modifying stuff nothing. just the exact same. im planning on making the entire rhythm heaven (i mean does anyone even know that game..?) saga in unity.
The game that started it all.
@queen adderBut I can append stuff to it and it grows
if your goal is to learn how to do that, then you'll need to figure out what parts you don't understand how to do and go learn how to do those things
no you cannot. unless you mean in the inspector which is a different case
Unity inspector also initializes the array for you
so =new is redundant when public/serializefield
Okay so unity set a size of the array? Because I could most def append to it when it was public
can u show what you are doing?
we're lost
doing so in the inspector is not actually resizing the array. it's changing the serialized data and assigning a new array of the different size
you cannot append to an array without creating a new array with the larger size
the camera in scene ?
yea
the camera's size is determined by not only the game view's resolution but also the orthographic size on the camera
This is what I did for testing before changing to list and events:
public GameObject[] _NPCs { get; private set; }
protected override void Awake()
{
base.Awake();
_NPCs = GameObject.FindGameObjectsWithTag(npcTag);
}
private void LateUpdate()
{
_NPCs = GameObject.FindGameObjectsWithTag(npcTag);
Debug.Log("Found NPCs: " + _NPCs.Length);
}
And this incremented as I spawned more npcs
the awake returns 0 as there are no NPCs
Find is making new array each time
this is not appending new objects to the same array. this is getting an entirely different array every time you all FindGameObjectsWithTag
you're also creating a lot of garbage by calling that every single frame
Yeah I know it is bad, which is why I changed it
LOL okay sure bro people are gonna do it anyway
a better option would be to use a List and have the objects register themselves with the object containing the list whenever they spawn
obviously , we just saying it isn't allowed to be discussed here
"pEoPle ArE gONnA dO iT aNyWaY"
and people are going to get muted/banned for off topic discussions
legal decompiling should be discussable
if its permitted then you outta ask the community of that specific game..
@slender nymphYeah I am doing that now
question-
how do I write a quarterion if I just want it to be 0, 0, 0?
Quaternion.identity
nvm
which is, btw, 0,0,0,1
figured a different solution out
So do I need to instantiate this: public List<GameObject> _NPCs { get; private set; } ?
Because this is not working in Start(): _NPCs.AddRange(GameObject.FindGameObjectsWithTag("NPC"));
rn the list is null
properties are not serialized by unity
declare an explicit backing field and new() that
I don't know what that means
so you are using properties and have no idea what they are?
you don't even need an explicit backing field unless you want to turn that into a full property. just slap an = new() on the end of that line
(I just used an existing "placeholder" transform value )
I don't know what " explicit backing field" means, no
Then Google it?
public List<GameObject> _NPCs { get; private set; } = new()
just do that
don't put _ for properties tho
why cant i do += here? how could i make it that it takes the previous value of hue and adds colorChange every time that code runs?
float newHue += hue + colorChange;
its local
you cant do += before assigning it
how would += even work there? newHue has no value until it has been assigned
because you are declaring a new variable
@rich adderCan't use with tuple type
also even if it did have its default value, that would be just 0 and 0 += anything == anything so the += is still pointless
what ur doing i have no lcue
Your code new()
if you are on 2020 or earlier you need to use the full new List<GameObject>() instead of the target typed new
Unity 2023.2.3f1
can you show what u wrote
public List<GameObject> _NPCs { get; private set; } = new ();
ohh the space?
that should work just fine unless you've gone and done something weird
Even without space
nvm im buggin lol
new List<GameObject>() works tho
weird
it should work fine, without...strange..
dont mind gray part editor does it auto
Where can I see C# version?
go to Edit > Project Settings > Player > Other and find the Api Compatability Level setting in the Configuration category in there and screenshot what you see, preferably the entire Unity window with that setting visible
I am still using visual studio 2017, can it be why?
yes
why are you using such an old version of visual studio?
Because unity was crying about visual studio code being deprecated lol
so you went and installed a 6 year old version of visual studio instead of the latest version that works perfectly fine? 🤔
you're like 2 major updates behind, even 2019 was installed by default with unity for the longest time
how would you guys create an item system where items drop with randomly generated modifiers?
holy shit wtf..
weighted
cause its ass
wdym?
Also, how would you implement it code whise?
oh you're talking about random stats to item?
well microsoft picked up vs code support for unity. however visual studio is still far superior (and likely always will be)
i've tought of SO's but they are unique and would be weird for multiple randomly generated items, but monobehaviour also seems like there's gonna be items with looooots of components so im not really sure haha
what are you exactly having trouble with ?
implementation, there are many ways and im trying to find the most elastic one
many ways to do something yes 😄
not to randomly generate stats, but to define what an item is and what a modifier is
hahaha yeah i have this bad habit of complicating my life
start small and expand
as long as you write proper extensible code
VSC is the best editor I've used, but studio might be better for unity I guess once you learn it
hmhm this is what im wondering what would be a proper extensible approach? ^-^
yeah right. Writing any .NET app in Code is painful
maybe its kewl for like Web/JS
Vsc is just vs stipped down. Which IS nice sometimes, I admit
Helo can someone help me with something
Im not sure how to get the drag and other options by the top left instead of it being on the play screen
extensible meaning you can add to it without breaking anything.
not code question
Which part are you struggling with? From what I saw above, all you need is to create a random value. I would use SO and have a min/max or a list of possible values then create an item based on that
How do I get these options to the top left like drag n stuff
Its stuck on the play screen
So continuing with my npc manager I have this right now:
private void Update()
{
for (int i = 0; i < _NPCs.Count; i++) {
AIBrain AIBrain = _NPCs[i].GetComponent<AIBrain>();
AIBrain.DoNextTask();
}
}
Is there a better way to call 1000+ npcs to do their thing? Should I use events on every NPC instead?
Store the AIBrain in the list instead so u dont need get component.
1000 get components per frame.. 
tell me if im wrong
the out keyword is a way to return a value and set it in a variable ?
its useful if you want to return multiple values without using a tuple or somethign else as the return value
other question : does the out return when reaching the end of the function ? or can it return earlier if not used anymore until the end ?
example :
with out:
void Start()
{
int enemyCount = 10;
modifyEnemies(out enemyCount);
// "enemyCount" is now 5
}
private void modifyEnemies(out int numberOfEnemies)
{
numberOfEnemies = 5;
}
usual "return" way:
void Start()
{
int enemyCount = 10;
enemyCount = modifyEnemies();
// "enemyCount" is now 5
}
private int modifyEnemies()
{
return 5;
}
how do i set smth to active if its within a certain range if it isnt then i set it to false
@eternal needleIn the same list? Like a tuple or what?
I believe you must assign a value to the out parameter before the function ends, whether that be before the last } or before the return
No just store the AIBrain instead of whatever you're currently storing
@eternal needlepublic List<GameObject> _NPCs { get; private set; } = new ();
What part are you struggling with?
do you know what a tuple is ?
all you need to do here is change the type stored in the List
Will I not lose the ability to access the gameobject if I need to then?
every component has a reference to its gameObject
all MB scripts have gameObject / transform references of the object the script is on/belongs to
im struggaling with 2 things 1 checking if it has a certain child component but thats not super important the main problem is checking if it is no longer in the range
i have this for the check the range
Collider2D[] colliderArray = Physics2D.OverlapCircleAll(transform.position, ShowInteractRange, interactableLayer);
You probably want to use a trigger for the range instead of this. Itll be easier since you have OnTriggerExit
Otherwise you'll need to compare the previous and current array
alright i can figure the rest out thanks
public List<AIBrain> _NPCs;
_NPCs[0].gameObject
Okay that worked, but now how do I fix this part if I am looking to add components instead? Do I need to loop through the results? _NPCs.AddRange(GameObject.FindGameObjectsWithTag(npcTag));
the best option would be to stop using FindGameObjectsWithTag
It would be better to just capture the instance when you instantiate
AIBrain prefab;
AIBrain brain = Instantiate(prefab);
_NPCs.Add(brain);
But some things are already in the scene when I look for buildings I do it the same way
Add them to the list via inspector then
That will be way too many
then have them add themselves to the list at runtime
Okay
how can i set the velocity of an object that has been created? i need it so an object is thrown th e same direction the player is facing
how do i do it so its thrown forward?
like is there a vector3.forward i can pass
get the object's transform.forward, multiply that by the desired speed and voila you now have the velocity
awesome thanks
Well, yeah. What inside that while loop would ever change ctx.performed?
That loop cannot end
i thought other things would be able to run while the loop happened
oh well you live and learn
That's not how loops work
Literally nothing else happens until the loop ends
how so ? code runs top to bottom, if its stuck on while it will never get to next line
i thought other scripts would be able to run i forgot how computers work
its possible only when using Async methods
Can anyone link a good video to begin learning c# with
there are beginner c# courses pinned in this channel
I recommend this text based tutorial
https://www.w3schools.com/cs/index.php
I do not recommend videos generally, especially not for learning the fundamentals of something like code
Ok
Ragdoll class
https://hatebin.com/tbziuunyqq
Limb+Limb info
https://hatebin.com/asjpqabfek
right now the ragdoll class is still in WIP but instead of RB I would just make the limb add itself to Ragdoll class @stuck palm
so ragdol in limb isn't doing anything for now
ideally Ragdoll class would just hold array of Limb
i dont need to use the action right?
not if you dont want event for a hit
for my use case i dont think damage is necessary or the action
yeah thats just for my FPS gun
i was just gonna do basically
if hit with an object faster than a given speed turn on ragdoll
well Ideally you want a hit then no ?
i also dont think limbtypes is necessary for my use case either, im assuming thats for damage calculation?
or are your colliders different from limbs
yeah exactly also for giving certain limbs hit a Push with RbAddForce At Position
you right actually
i'm just gonna set up the joints
yeah start with that then worry the code
is it the "character joint" component?
indeed
right, i think i should make the colliders first
Custom Ragdolls! You can use a Ragdoll on every amature based Object you want. I have chosen my bear object in my case. In this short video I will demonstrate how you can setup your custom ragdoll to use this on animals, monsters and every physics based object you need.
I provide you the complete project, hopefully this will answer every questio...
its a painful process without the wizard 😅 but doable ofc
so do i apply just like one big collider at the armature root? or do i apply small rigidbodies for each limb?
I have a capsule for solid collisions and my limbs are triggers until the rigidbody is activated
my ray is set to ignore the solid collider
you dont have to do it that way ofc its for optimizations for me
that would be a solid collider 🙂
yeah so i guess i'll just make colliders for the limbs now thne
its hard to make changes when the colors blend in to each other 😭
but CC will get in the way
so you have to use Layer based collision to ignore the main CC
naa jus time consuming
np!
so the idea is, at the root have the ragdoll, each limb has a collider and limb class
give limb class a limb type or something
what then?
each limb also needs rb
say i have a simple plane, i then scale it, and some function modifies the mesh and bends it/extrudes it. I would like to iterate over the new values for the vertices, but mesh.vertices doesn't change; is there an easy way to do this?
do i just mutiply the vertices by the scale and add position offsets if the mesh has moved?
this is a rly dumb question but is vscode better than jetbrains rider for unity for coding
rider better
oh fr?
helps you with code smell and just generally feels better
oh ok
thats like comparing a ferrari with a pinto
is free?
has direct unity integration so it has docs loaded up and stuff
its free if youre a student
only for students
at college or in general
you need a school email
to apply for github student
oh bet
i aint goin throug all that im just tryna make a player than can move XD
ok
y are there so many versions of vs
but close enough
because microsoft though it was smart to make another code editor with the exact same fucking name
dam
yeah idk what they were thinking lol
@rich adder is the IDamageable class necessary for your code to work?
its an interface
is it necessary , no . My gun just uses that to interact with anything that has that
yeah i'll get rid of it then
this way my Gun doesnt care about limbs or anything
its not necessary for my thing
its still good practice to use abstractions like that
where do i apply character joints?
wow it takes a long time to install unity editor
did you see the video
each limb has a joint
oh i didnt mb
i'll watch now
i was just busy getting all the limbs and colliders and rbs 😅
depends on ur PC / internet
Hey guys, I'm making a flappy bird ripoff game and I have a bug where when the bird dies (but still manages to get through a pipe by momentum) the score still increments.
I'm trying to fix this by referencing the gameOverScreen gameobject in a script for the middle gap trigger between the pipes (which is where the score is added).
Problem is, I can't seem to properly reference the gameOverScreen gameObject in the middle pipe script, since the pipe is a prefab.
If it's a prefab why don't you simply assign it in the editor
because prefabs cant reference scene objects
this should work fine
When the bird dies, deactivate its collider
except activeSelf should be checked to true if you used this script
so technically it would work
if(gameOverScreen.activeSelf) return;
but yeah disabling collider is prob better
also Logic can just hold Reference to the GameOver screen and you can also access it tat way instead of 2 Find calls
then I'll have to make another ref to the bird this time
i was using layers to check where the birdobject was
hello have somone few munites to help me understand some thinks? im gonna use chat GPT too but i need help to start and understand one thing
wait ur right ill try that
Ask your questions here and people will help if they can
stay away from GPT as beginner
why?
because it will mislead you to think something its spewing is true
which is a flip of the coin
no memes plz @potent echo
but yes is true
mb
Ok so i want make Android aplication to randomizer image monsters from Witcher. And it was fine chat GPT generete me ok code and that was it. But now i wan to make animations of this monsters as .gif or .mp4... and its starts problem. Bcs i dont know how ask GPT to help me. And i rly dont know how to use this... what is better u think .mp4 or .gif?
collision contains a reference to the bird here
#💻┃code-beginner message
collision.collider
@rich adder doesnt seem to be working very well LOL
how many limbs do you have? cause wizard should still work on this cahr
just exclude the extra ones
11 bones
is CC colliding with limbs?
i disabled the CC when i did this
that screenshot rather
Why does this not work:
private Home _home;
...
Home home = NPCManager.Instance.GetHomeByIndex(1);
_home = home.AddTenant(this);
NPCManager:
public Home GetHomeByIndex(int index)
{
Home home = homes[index];
if (home == null) return null;
return home;
}
hard to tell what going, it does look like is working
I'm a bit confused, how do you currently generate those images?
Your goal is to generate animations from images? That's like ultra advanced stuff
might try the wizard, but i also dont wanna delete my work with all the colliders i made LOL
this method doesnt return anything
i'll make a duplicate prefab and t ry that one
yea def
would the IKs in the arms be interfering?
nah i also use IK
well
depends if you have the IK active
iirc it only works with Animator active but forgot
Is this a good place to ask for some pointers to some tutorials?
it is active but i doubt thats causing the seizure
possibly , make a vid of issue cause its hard to see that in ss
Oh derp
okay one sec
sure if its code related
With the help of GPT chat, I created a working program that generated random images as .png files. However, I would like to change these static images to moving images that I already have prepared as both .mp4 and .gif files. But here's where I'm facing difficulties because I have no idea how to approach this... That's why I'm seeking help from someone who could assist me in understanding the basics, which I could then use to work on further modifications myself.
I played around with unity a year or so ago and I’m looking for some tutorials for making a 2d fighting game, I just want to make sure I’m watching something up to date/good
So you are asking how to generate videos from images in Unity.
Do you realize how advanced of a task that is? And likely something that nobody here has done
rather than trying a specific game I would personally start with learning the Ins and out of the editor and then the components and then coding concepts like basic c#
okay so character controller was on, turning it off fixed it lmao
haha nicee
I thought Unity supports .gif images, and it would be just about replacing .png images with .gif ones here."
If I deactivate the collider, won't the bird end up passing through objects as soon as it's dead?
So do you already have existing PNGs for the frames of those videos?
Yeah I made a small game with it before, I guess I’m not looking for something for the type of game I’m making specifically but just up to date tutorials for 2d, building a level, the new input system, best practices, etc
i have .gif files like this one
Lots of stuff I find is like 5 years old
code doesn't change
You need to break it into frames I assume
only the editor UI
how?
I mean stuff does change like the input system
@rich adder right so it fixed for a bit, but i tried something and now this is happening, any idea what might be causing it?
well new Input system is a new thing but you can still use old input system
Yeah, that's pretty common. And not triggering any OnTrigger message
Don't you reset the scene when it dies?
Reactivate the collider if not when you want to start over
ohh weird something is wrong with one your bones
does Transform.Find generate garbage?
any alternatives?
I dinno about allocating actual memory. But yeah, avoid find always
the one thats staying in the middle? thats the root armature
There's a gamOverScreen UI that appears, but you can still see the bird, and it won't be the best looking
Fair enough
that might be the issue
It will fall out of view right?
Otherwise check if it's dead before adding to the score
Make a bool on the bird and get the bird script from collision
you can see in the wizard that Hips or whatever the root is must be added too
if the bones are connected you cant separate them like taht
I guess I was more so wondering if there was a good recent 2d tutorial anyone would point someone new to
yeah, but since I'm using RigidBody for the physics, the bird's momentum carries it forward
So? VERY normal for games like that
But yeah, since you seem to really not want that, do the other suggestion I made
Can't you just use the video directly in unity? After converting to a compatible format if neeeded
Or use a png sequence like suggested, not sure how you would play it back then though.
just fixed the issue, just realised that it wasnt connected to the rigidbody of the player root
will do, thanks
honestly it should work if you just do
if(gameoverScren.activeSelf) return
so now i've got the ragdolls working, how can i active and deactivate it at will?
I think the original issue what that they struggled to reference the gameOverScreen
At this point I can't remember 😸
At least they get bird from collision
collision.collider apparently doesnt exist when using Collider2D
ohh because the Find in the start thought it was working myb.
? Why would you do collision.collision?
collision.gameObject.GetComponent<Bird>()
Or whatever you called the class
Ah
well do you have animator?
That exists though
that usually overrides the physics
Collision2d definitely has a collider reference though
https://docs.unity3d.com/ScriptReference/Collision2D-collider.html
Ah, you used OnTrigger
It gives you the collider directly, not collision
yeah i have an animator, but how can i disable the physics of the root entirely? if i make it kinematic it looks like the character controller movement doesnt work
why would kinematic rigidbody affect character controller
just make sure they are not set to collide with each other with the layer based
yeah you right they arent actually
i think i just did it wrong the first time
how I set it up is as follow
Rigidbody limbs
Kinematic rb + Trigger Colliders
when I need ragdoll
make RB dynamic and make colliders solid
I start them all as Kinematic and Triggers already in unity inspector
having them as active rigidbodies will be awful performance if you're moving with CC
yeah fair
so if theres a collision with an object, do i have to do anything with that action whatever youve made?
if i do protected static Strings strings { get; } = new Strings(); in parent class, will it create new Strings each time child class created?
i was just gonna activate the rigidbody and let the collision do its thing
Each instance of the child class will have their own Strings, yes
wdym im confused on that?
do you mean if like a box hits it?
yeah
the game im making is like people throwing objects around
What are you trying to do?
you could potentially use OnTriggerEnter
or boxcast / overlapbox from the object
Why would the blood tag one not be working while the gas tank one is working
i was just gonna do so like if the box hits the main capsule at a certain speed, enable ragdoll and just let the collision happen but idk if because its kinematic it wont do that
missing tag on hit prob?
What is "hit"? Is it a collider?
well depends how accurate you want
I dont use CC for that because I want actual limb specific collisions
I only added the blood one, the rest was there before hand
yours can work fine in your usecase tho @stuck palm
yeah, i dont really care about limb collisions in this case i just want the player to fly off when it gets hit lmao
If the collider is a child collider then it will check the child's tag
And ofc make sure you have the tags set up snd assigned
i have class Root that is parent for all other classes, and it contains static variables for gameController and similar things that need to be on the scene, they assign themselves to static fields in Root in their Awake. But now i think i will just make new static class Strings instead of putting one in Root
it will do similar
yeah just iterate through it and set each limb to kinematic = false and collider.istrigger = false
but if it is in Root it will be prettier
the tags are assigned properly, the collider in my case are on child objects while in the rest is on the parent. does this make a difference
yeah ima do that, thanks for your help with the basic framework though man, really helped me 😄
@terse osprey instead of GetComponent, use collider.attachedRigidbody to get the rigidbody. This way it works if the collider is a child
sure np 🙂
Rigidbody rb = hit.attachedRigidbody
Instead of the line where you use getcomponent to get it
It depends how you set things up. You are currently trying to check tags and get components from the collider, which might be a child.
You can try using the rigidbody's gameobject if it exists. Otherwise use the collider
Or use GetComponentInParent instead of GetComponent
the rigid body does have a game object such as "spine" or "hips" , etc and they have the assigned tag of blood. But these rigid bodies are children of the main prefab
Btw the GetComponent<Collider> is absolutely useless here, you are already referencing the collider (hit)
Start by using Debug.Log to print the hit object's names and tags
is hit supposed to be the name of the collider, I am a little confused here. Sorry for being annoying
Yes, hit is a collider, you are looping an array of Collider
I would definitely name it collider or hitCollider though, to avoid confusion
this doesnt seem to be working and i dont know why, the layer mask has been set properly, and im not getting anything printed to the console
why layers and bit shifting like that ?
quick question, if I have a class containing several buttons, how can I make the button force a change in a button manager?
make events in the button that button manager subscribes to
idk, its just something i saw on a unity forum and it works with the other collision thing im doing
not even the first print is showing up so its as if nothing is even colliding
Is this script on your bodyparts which have kinematic rigidbodies?
public class Buttonmanager : MonoBehaviour
{
[SerializeField] priavte Smallbutton[] buttons;
void Sub()
{
foreach(var button in buttons)
{
button.OnClick += Button_OnClick;
}
}
private void Button_OnClick(Smallbutton buttonPressed)
{
//do stuff with buttonPressed
}
}
public class Smallbutton : MonoBehaviour
{
public event Action<Smallbutton> OnClick;
void Thing()
{
OnClick?.Invoke(this);
}
}```
no, its on the root gameobject. looks like there isnt any collision happening
Did you say you are using CC?
yeah, but theres a kinematic rigidbody in there too
the big capsule around the player is the CC thing
which one do you want to be message invoker?
Not sure if even kinematic rb works with CC
made the cc radius a bit bigger and it seems to activate it, so
so many colliders I can't tell whats happening xD
@rich adder thx!
Is this script for when the ragdoll is active or inactive?
its for when its inactive
tryina show u how I did hit by box go flying..but my unity been stuck like this for 20 min
random unity bullshit.
lmao, appreciate the effort anyways 😭
you can see how making the cc collider a big bigger makes the collision happen though, right?
Rigidbody probably can't use CC to detect collisions and it only works once one of the bodypart colliders hit something
Which happens after you adjust the CC radius so that it clips thru
CC can only call OnCharacterControllerHit otherwise u need trigger
the box is the scan, its its own thing
i guess i could use that instead?
yeah put that and detect the box from there instead
record the velocity before the hit so you can tell which direction / force it was hit with
since it 0s out onHit
how can i record that? from the moving object?
doesnt seem to work as intended 😭
Could someone help with me with the onClick event for buttons?
I'm working on the 2022.3.5f1 version of unity and its onClick event for buttons ask for parameters that I'm not familiar with, such as mode and target assembly. What am I supposed to input for them.
maybe maybe
the object can call the collision?
i mean the object can call the ragdoll activate?
both can
store it in vector 3 and only update it if not collided
its just cus if u watch the video you see that the ragdoll only works once the player runs into the object
show the current code rq
are you in Debug mode in the inspector?
private void OnControllerColliderHit(ControllerColliderHit hit)
{
print("collided with " + hit.gameObject.name);
if ((collisionLayerMask.value & 1 << hit.gameObject.layer) > 0)
{
print("tripping!!!!");
ragdoll.Activate();
}
}
what is the print saying ?
and why Use layers just check if object has a rigidbody and speed is High
guess i could do that, yeah
its saying "collided with DroppedItem"
is that when it gets hit by flying box? and what is Doppeditem
lemme record vid one sec
it will explain better
Just wanted to report that this worked like a charm ❤️
You're welcome! 🙂
it decided to work this time 😭
maybe it wasnt being hit hard enough or something
lmao
sometimes it seems to teleport the player on top of the thrown object, though
is there a way to like
keep the momentum?
pass the Box's velocity before hit to like the chest rigidbody or something ( you need a reference stored on the char)
so it goes flying backwards
is there a way to inherit animator controllers in such a way that enables the user to add additional programs? And I am not talking about animator override controller. That only allows changing animations of states
reference of the body or the velocity? soz im confused
Reference the Chest rigidbody on the player
Record velocity of Box rigidbody right before it hits
when hit AddForce-Impulse mode to that Chest Rigidbody
ah right, thank you. how can i record the box's velocity before it hits again? you mentioned a vector 3. maybe like in fixed update or something?