#💻┃code-beginner
1 messages · Page 47 of 1
because if the surface is irregular, you don’t want to get fucked by edges
raycasting works, but will look super wrong whenever the surface changes slope
because the spider (which lacks collision) will have part of him just clip right through the world
i know people like raycasting because it’s cheap, but casting shapes helps prevent jank
do you understand?
@forest wolf thanks for the help I'll try those
Good luck! If you get stuck please let me know :)
i do
i don't really care about that, we dont have the time
its a uni project. 3 Months to do a 3D multi leg procedurally animated in a game
in this snippet you set the rotation, where do you set the position?
from 0 exp on unity
then after your transform.position += line
but its not in the same script
give me a sec, I need to open rider to add the lines I need :)
by the way, instead of doing screenshots it's better if you do
3x ` and then add C# then after the code add it once again
oh yeah that too
you will have something like that
var trolo = hey;
*CSharp not C#
or cs
@somber wren I think something like that could work:
private void Move()
{
var t = transform;
t.position += (t.forward * ForwardInput * Time.deltaTime * _moveSpeed);
Physics.Raycast(new Ray(t.position, -t.up), out var hitInfo);
var currentDistance = Vector3.Distance(transform.position, hitInfo.point);
var distanceAdjustment = TargetDistance - currentDistance;
t.position += t.up * distanceAdjustment;
}
if the raycast doesnt work then currentdistance is 0 ?
you are a wizard
thank you
but it wont work ON my cube
it just goes through
and yeah sometimes it goes in the infinity under the ground, i will raycast from my raycaster
oh sorry, did you manage to get it working? I maybe missed something as I haven't tested that snippet
xd look
Can you add Debug.Log($"{currentDistance} adj: {distanceAdjustment}");?
By the way if your spider is always lying on the surface then you don't even need raycasting and calculating the distance adjustmenet. If the distance is always 0
then you should be able to do only t.position += t.up * TargetDistance;
wdym
no xd
its going up to the infinity
i can't recooord aaa
im on da wall and then pouf
fucking up in edges yes
heey, does anyone knows how could i do this to make a fade transition?
and if you use the adjustment?
it works
Just add in the canvas empty image, set the color to black. Then add canvas group component to it and you can simply animated the canvas group's alpha from 1 to 0 or from 0 to 1 depending if you want fade in or fade out
Hello everyone
the ray goes on the wall :(
I am following a tutorial to make a vampire survivors like game and I am stuck at cinemachine part. I selected the virtual camera to follow the player, but it doesn't follow him
Oh that's fun! In that case probably better would be BoxCast rather than raycast
and the box would have to have size of the spider body
wow why XD
i don't know if i expressed good my self... i want all canvas to fade to discover what is under the canvas,,, Like disable the canvas but with a fade... is there any way to do that?
i never used it wow
put a canvas group on the GameObject and animate the alpha property . . .
oh, right, thankss
and how could i get access to alpha parametter?
save as mp4 or use http://streamable.com . . .
the same way you access any member — property — of a class . . .
my bad, I forgot to change the type
how can i stop players from spam eating and drinking as shown in the video? like if they switch to another item they can eat or drink straight away
using System.Collections;
using MilkShake;
using UnityEngine;
public class Food : MonoBehaviour
{
[Header("Item")]
public ConsumableItem item;
[Header("Eating")]
public bool isEating = false;
public float eatTime = 5;
[Header("Audio")]
public AudioSource audioSource;
public AudioClip eatClip;
[Header("Shaker")]
public Shaker shaker;
public ShakePreset eatShake;
private void OnEnable()
{
item = HotbarManager.Instance.currentItem as ConsumableItem;
}
private void OnDisable()
{
item = null;
isEating = false;
}
private void Update()
{
if(Input.GetMouseButtonDown(0) && !isEating && PlayerHandler.Instance.canUse)
{
StartCoroutine(Eat());
}
}
private IEnumerator Eat()
{
isEating = true;
Statistics.Instance.currentHealth += item.health;
Statistics.Instance.currentHunger += item.hunger;
Statistics.Instance.currentThirst += item.thirst;
Statistics.Instance.currentStamina += item.stamina;
item.cell.SetAmount(item.amount - 1);
audioSource.PlayOneShot(eatClip);
shaker.Shake(eatShake);
yield return new WaitForSeconds(eatTime);
isEating = false;
}
}```
i was maybe thinking have a static bool which goes across all food scripts
to check if you can eat?
idk
be sure to look at the CanvasGroup type in the !docs. it gives you all the details . . .
do you have a cooldown before they can consume again?
i have the coroutine
The static bool will work but it is ugly from the perspective of Object Oriented design. The issue is that "Eat" is on the food item. Item can get eaten but it's eaten by a player. In that case the controlling item should have a field for 'isEating' or even better more generic 'isBusy'. Player's 'use item' method should check if the player is busy doing already something different
it works when i dont switch items
is the coroutine for each food item? if so, then it'll only work for that specific item because each item will have thier own . . .
Then maybe 5 raycasts? From each corner and the middle of the spider?
all the food items have this script
at the top of a script:
public CanvasGroup myCanvasGroup;
private bool isAnimating;
private float animationTimer;
private float animationEnd = 1f;
void Update()
{
if (isAnimating)
{
animationTimer += Time.deltaTime;
AnmiateFadeOut();
}
}
public void ToggleAnimation(bool animate)
{
isAnimating = animate;
animationTimer = 0;
}
private void AnimateFadeOut()
{
myCanvasGroup.alpha = Mathf.Lerp(1f, 0f, animationTimer / animationEnd);
}
Then check those that hit and are the 'shortest'
how do i get each corner and how do i know which one is good. I only need 3 tho, one at the front and one at the back
you create an empty object and make it child of the spider. You then create a serialized fields for those transforms in your script. Drag & drop the game objects into the fields in the inspector - boom you have transforms with positions :D
u can see how the objects are getting activated
and deactivated
thats the problem
because on disable i do this
smart
@tender stag that's the problem. you need a controller/manager that controls the consumption of consumables. when a food item is eaten, a timer on the manager runs. switching to any food and attempting to eat will send an event to the manager that will determine if they can consume again or must wait . . .
would a coroutine work if i start it when the object is still activated and then i disable it like half way through the coroutine?
If the coroutine is on the object that is getting deactivated it would stop
This is like the 4th time you've said this i did what the instructions said nothing has worked 💀
Why would you complicate it like that? Seriously, the easiest way to control that is to put the controlling field on a higher level - like the player or manager
a coroutine will stop if the GameObject it's on is disabled . . .
just create a manager that controls the consumption. that's the simplest solution . . .
so i could have like a manager for each of the categories?
and just place them on like consumables, weapons etc
Can do OnDisable() to flag that the coroutine should end early
@forest wolf doesnt work... sigh
what's the result? In what way it doesn't work? :)
quick question, if something is moving will it always have a velocity above 0, and if it is not moving will it always be 0
Depends on how it's moving
isnt there - velocity as well
Is it using transform.position += ?
nope
Not even manager, holder holds an item, each items, be it weapons, consumables or tools can have a common interface "Usable" or something like that that have method "Use". Each item could implement the interface and thus the method. Then the holder could execute the use of any item that you are currently 'holding'
That is one way to move it yes
velocity is determined by the physics engine. if you're not using that to move, then velocity is unaffected . . .
ok so if it is stopped it will be 0 velocity
Well, need to know how it moves..
Should, yeah
you can easily test that out. move and object and check its velocity. stop the object, then check its velocity . . .
how do u see velocity
nvm
i think i know
again — as we mentioned — it depends on how the object is moved. if using the physics engine, access the velocity property of the rigidbody. if manipulating the transform, you need to get the distance from the current position to the last position . . .
This is definitely a beginner question, and maybe not all that important, but I keep getting the following error when I stop the Play in my editor for a singleton:
Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)
The following scene GameObjects were found:
InputHandler
And my InputHandler.cs has this:
//Create a Singleton for this InputHandler Static Class so it stays on Scene Change
private static InputHandler instance;
public static InputHandler Instance
{
get
{
if (instance == null)
{
instance = FindObjectOfType<InputHandler>();
if (instance == null)
{
GameObject obj = new GameObject("InputHandler");
instance = obj.AddComponent<InputHandler>();
}
}
return instance;
}
}
private void Awake()
{
DontDestroyOnLoad(gameObject);
}
//more code not visible that handles input
void OnDisable()
{
Destroy(gameObject);
}
It's not breaking anything, just a little annoying. Any help would be appreciated! ♥
i have a new idea that should work
Why do you destroy it in OnDisable?
Also, you don't really wanna do new GameObject
You want Instantiate
even if I remove the OnDisable() the same error occurs.
ah ok, let me try that.
heey, how could I do on the last methodCanvasFadeto instead change the alpha from 1 to 0 directly to make a fade changing alfa softly? ```cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LoadingScreen : MonoBehaviour
{
[Header("Preferences")]
[SerializeField] private float loadingCanvasTime;
private float loadingTextTime;
[Header("Drag")]
[SerializeField] private GameObject loadingCanvas;
[SerializeField] private CanvasGroup loadingCanvasGroup;
void Start()
{
loadingCanvas.SetActive(true);
loadingTextTime = loadingCanvasTime - 0.5f;
Invoke("CanvasFade", loadingCanvasTime);
}
private void CanvasFade()
{
loadingCanvasGroup.alpha = 0f;
}
}
Ah, I didn't think that was the issue. Just wanted to know. Can't think of a reason to do that
Also, I don't think the Instantiate thing is the issue.
I dunno what is causing it, sorry for the confusion
Start a coroutine that lerps the value
You could also skip the invoke by doing that
ya Instantiate has the same error. 😦
@pastel marten using new GameObject() is fine here . . .
Ah ok
you can use a coroutine and wait for x milliseconds while changing the alpha little by little
but dont return null. then youll need to use time.deltaTime
Is it just a weird Editor error? Maybe it won't affect the build?
take a look at coroutines. there are some video resources online . . .
@dry tendon oh its you
I can show you by DM, I made the same youre trying to do some days ago
hehe, better
I'll do it, thankss
what intellisense pops up after you enter current.?
yea but i thought most ppl dont do it like that
there is like 10 different ones
but it is all just cuz its number
also no one seems to know here
so ill put in code genereal instead
have you asked this question multiple times?
nope
this is the first time i've seen and you've barely waited for anyone to answer . . .
there isn't a hundred people waiting for questions to pounce right away. you seem impatient . . .
yea but it is not really beginer if the average person doesnt know, if you dont know that is fine just leave me be
did you check the docs for the Keyboard class to see its available properties?
have you checked anything online?
is this the old input system or the new input sytem? try to provide more details . . .
new input system
it was just a method i saw by someone and used it as it is alot more simple than other methods
ty, i saw this website but i didnt know it would say how to do it for every key so i went off of it but the problem seems to be solved
my search brought me here. you need to look at the docs for the Keyboard class where all of the available keys are . . .
yea i did get there, but i didnt know that the docs explained it for each key so i clicked off, at least ik for next time
is there a simple way to make a given field/property only accessible to its class AND one specific class that is not derived from it?
You could always just look at the autocomplete suggestions
C# does not have a friend equivalent, AFAIK
(C++'s friend keyword allows for this)
no problem, next time continue reading and/or scrolling through the docs. don't just click away . . .
No. You cannot specify which classes have access to something.
i didnt see them, after i type smth it just removes them for me i think
nah, c# don't play favorites . . .
😦
events
there is one simple way to do it, put both classes in one assemdev and make the field internal
Perhaps you should add a nested class that holds a reference to the class, and then offers a property that gets and sets the class's private field
c# friend classes when
You would then hand an instance of this class to whoever needs access
private int test;
public class Gimme
{
public Entity entity;
public int Test
{
get => entity.test;
set => entity.test = value;
}
}
(the enclosing class happened to be named Entity here)
Although, this has a public constructor, so anyone could make an instance of Gimme
I'm not sure you could make this work. If you made the class private, then you could not return it from a public method. If you made the constructor private, the enclosing class couldn't call it
I suppose the problem here is that we're trying to do access control programatically (making something that's nominally public, but can only be granted if certain conditions are met)
it just doesn't really jive with the completely static nature of access control modifiers
This is a very beginner question. I would keep it here
ok
Hi
Does anyone know if there's a way to get the object who sent a log in the ILogHandler methods?
this is weird. i figured it was the OnDisable method. most people with that have smth in OnDisable or OnDestroy . . .
You shouldn't be constructing anything derived from MonoBehaviour. I believe ScriptableObject also wants you to use CreateInstance to get new instances.
The former has a very obvious reason: components must be attached to a game object
so a free-floating component would be nonsense
I dunno about scriptable objects.
I removed the OnDisable and OnDestroy methods, still getting the error. 
I think I recognize this.
When you're unloading a scene, objects get destroyed immediately -- so they wind up equalling null right away
I had some components that were trying to access a singleton while exiting play mode
smth is trying to access the Singleton after its been destroyed . . .
that's what i've come to . . .
The singleton would get destroyed first, so the singleton class tried to find them again
It would get a bogus object reference back (because there was no valid instance of the type it wanted in the scene)
and then overwrite the existing instance variable with it
So I lost the (still totally usable) reference to my destroyed singleton and got a new (unusable) reference to nothing
In this case, you're constructing a new game object when you notice that the instance is null
So if anyone tries to access this singleton during scene unload, a new game object will be constructed
I'm not sure what the best option here is
You could try to get rid of the use of the singleton during a scene unload, or you could make the singleton not try to find an instance if it notices the game is quitting
they'd have to add a check if the scene is getting destroyed or reloaded . . .
that sounds tricky to solve correctly
it'd have to create itself in a valid scene
but what is the correct scene?
If your code accesses the singleton while the current scene is unloading, there would be no valid place to put the new object
Well... it's just an annoying error in the Editor I suppose. It shouldn't affect the build or anything should it? I can just ignore it?
im watching a video for some movement tips, and he uses some characters inbetween thrust1D > 0.1f and thrust1D < 0.1f, i cant tell what they are, anyone knows?
and how do i type said symbol?
Entirely depends on your keyboard 🤷♂️
Mine is above the enter key iirc
On my phone though
@swift crag @cosmic dagger
This makes no sense to me at all, but the error magically stopped after adding a GameManager class and DataSaver class for player traits & stats.
GameManager script: https://pastebin.com/XH1VcR8e (updated)
DataSaver script: https://pastebin.com/s6bDAJXZ
Doesn't make any sense? But at least it's gone I guess... lol
Hello there. :D Good to be back. :)
I'm sort of trying to get my camera working in a unity project. It doesn't move in scene view despite any changes in inspector :C
what does this have to do with code?
It moves in the actual view but turn on game; jumps to some high zoom
what, oh, maybe it doesn't.
Well maybe it does
where would I go with this?
that sounds like you have a script that is setting the camera's position
I don't think I do. :C I just set this up. imma go look around.
that would explain it for sure.
objects don't move on their own
some component will be doing it
either a script you write
or some other component you added somewhere
yeah I just want to set the starting location.
you need to make sure your script respects a starting location and doesn't just trample on it
If you script sets the position to [0,0,0], it doesn't matter where the camera was
no script yet. are you saying I can't setup a camera location without a script? there's always this:
It's gonna end up at [0,0,0]
no, we did not say that.
Praetor suggested that there is a component in your scene that is setting the camera's position
Show the whole editor, including the hierarchy, with the camera selected
very beginning. don't think I have any components, unless they come with the basic setup. but can't find scripts just typing scripts to search.
and what happens when you play the game?
Show the same screenshot once play mode starts
so, start the game, click back to the Scene tab, and screenshot that
Looks to me like you're just confused about how UI works TBH
oh, yes, you're trying to show an image on a Screen Space - Overlay canvas, aren't you?
because now you're looking at game view
well, as far as my confusion goes, there's some values on the right, and I can't alter them to alter this camera view.
The canvas appears in the scene view so that you can work on it.
right because the camera has nothing to do with how screen space overlay UI is shown
it's not shown on a camera
it's overlaid on the screen directly
right...
double click on your canvas in scene view and turn on the "rect" tool
position your UI as desired there
So the camera IS moving. The canvas is just always gonna overlay it wherever it is
So there is nothing that will obviously LOOK like a different position
if kinematic RBs in 2D use velocity, what happens when you MovePosition and also have velocity?
I am getting weird interactions when rotating my player where I stick to walls ass if my capsule collider was a rectangle that is clipping into them
how come there is an issue, i just want to get the currentTime from timeScript and round it to nearest whole number so it can detect if the currentTime == 5
dot notation is for accessing members of a type . . .
yea but where do i put round thingy then
Math.Round is the function, you can pass timeScript.currentTime to that
fn(args) is how you invoke functions, so Math.Round(timeScript.currentTime)
.(Math.Round) makes zero sense
That would imply timeScript has a member named (Math.Round)
(Math.Round) is not a member. Math is a type with a method named Round. i don't know why you have it surrounded in parentheses . . .
which cannot be since you can't have parenthesis in a variable name
what does the error say now?
@bitter carbon that's not what i said to do
doesnt work as its if statement
it needs (
no
This is calling Math.Round on timeScript.currentTime == 5, which is a boolean
it doesn't work because everything is out of order
no, that's not relevant
You're attempting to round a "yes" or "no"
read your error messages.
You should probably look at the Intro to C# link in the pins to see how C# syntax works
Math.Round(timeScript.currentTime) is how you get the number, then you can compare that to 5 outside the function call
i would understand what you're trying to do first, then take it one step at a time instead of randomly guessing . . .
ik how it works its just sometimes i forget certain rules
This isn't "forgetting rules" this is a significant misunderstanding of the . operator, parenthesis, and functions
You really should make sure you understand the basics before attempting to continue
these aren't "certain rules"
this is a very fundamental concept
Learn C# properly. It will save you a lot of time in the long run.
this is extremely incorrect syntax
ok ik how it works now and its unlikely ill do it wrong again, also ik certain concepts more than otehrs so me being bad at one thing doesnt mean im bad at everything
i do
No one said you were bad at everything but you do seem to be bad at syntax which is why I suggested going back to the basics on it
give me a certrain question and ill try answer it
You have to understand that Mathf/Math are static function classes and not extensions of types
wot
"and not extensions of types"
I don't understand what you mean by this.
whatever . is called
what is the terminology
. is called dot notation . . .
Member access expression
UnityEngine.Mathf.Round
UnityEngine is a namespace, so UnityEngine.Mathf retrieves the Mathf member from the UnityEngine namespace
Mathf is a class, so Mathf.Round retrieves the Round member from the Mathf class
it is how you access —public — members of a type . . .
I know what it does, I used the wrong terminology
well, members that you have the right to access, in general
It's actually a struct for some fuckin' reason
is it best to use a for loop if i wanna do it like:
if (time) is 5 seconds add 1 to decay etc,etc.
huh, the more you know
no, please, don't get into that. it makes no sense (to me) . . .
C++ does weird stuff like this to, at least in Unreal
C++ is made entirly of weird stuff
was it truly easier to write that and make us decipher the handwriting?
i can read that easy, that is like my normal writing
I sure hope you can read your own style of writing
i can
And I remember it being not static for some reason? Like you could do new Mathf()
Might have mixed it up with something else though
Well obviously. But you being able to read it has no bearing on whether others can. You have experience reading it lol
I, for example, cannot read that
Wouldn't surprise me. Of all the archaic decisions this is the one that leaves me the most baffled
hm ok, next time ill just type it out
Allow me to translate.
;f 5 sec I decaw
jf 10/1s see deeey
it 21/26 🐙c dean
I wouldn't say a for loop is the best for that, you could use a Coroutine or Update tick to count time passing and then execute code at intervals
i already have a time counter so ill just need to add it in,
i think ill just try with for loop and see if it works well or not
What are you looping over
A for loop is used to execute the same block of code many times.
I don't even know how you would loop over that
If you want to perform an action every time a certain condition is met, a for loop is not appropriate (by itself, at least)
where can i read about for loops as i cant find anywhere
you don't want a loop
I continue to insist you need to stop trying random things and follow some tutorials
It is absurd to claim that you "can't find anything" about for loops
What are you expecting a for loop to do
Also this. Literally millions of pages looking up for loops in C# or Unity
this is a ridiculously bogus statement . . .
ok everyone calm down i found one, it just i waslookign one from the unity documentation site
but ill use a different website instead
loops are a coding concept not unity
This won't do anything for you when you are talking about adding something after a certain time
for (i = 0; i < someInt: i++) {}
it is fine to not understand, but it is unreasonable to pretend that you do
you're doing yourself a disservice
Maybe this one:
#💻┃code-beginner message
When I am trying random stuff or even needing to check something, I always use: https://docs.unity3d.com/ScriptReference
You may not get much out of it if you're not very familliar with Unity/C#
Don't look on Unity docs, even for unity things. Google it and get the docs that way
You had that issue yesterday too iirc
And it WAS a unity thing you couldn't find
yea i think googling is alot better
how can I get RaycastHit2D[] normal?
Yeah never search the site, use google and look for the link XD
Ik that RaycastHit2D hit would just be hit.normal but I cant find it
Which one do you want the normal of
normal of this
that's an array. you need to access an element from the array first, then you can access its normal property . . .
ohhhhhh
Which one
yah it worked
can someone pls explain differenece between || and | (ik they are both or but i dont understand differece)
when it hit the wall
but I already have a foreach loop that checks it
if you only care about the first thing it hit just use hitscan[0]
I was trying to access it directly from the variable name
I thought it would give me the full length of it
|| is conditional logical OR operator .
| for integral numeric types,
ok thanks
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/boolean-logical-operators
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators#enumeration-logical-operators
C# logical operators perform logical negation (!), conjunction (AND - &, &&), and inclusive and exclusive disjunction (OR - |, ||, ^) operations with Boolean operands.
i'd say it's a bitwise operator more than it's for enums . . .
true, was trying to oversimplify . edited 🙂
aren't all single operators bitwise and doubles are conditional?
when I redo a raycasthit2d[] from inside of a foreach loop that is cycling thru its elements does the foreach get updated?
with the new raycasthit2d
if you re use the variable it will overrite the previous array
but the foreach loop will restart right?
or will just end
it would restart
the loop would finish first
great to know
it won't restart unless you tell it to . . .
It would finnish the previous array and end
it says | will look at both x and y whereas with || if x is true it only looks at x
it would not restart, my bad
code only does what you write . . .
how do I tell it to restart?
Would that not just result in an error? something something dont modify collections as you foreach over them
you cannot change or edit an array if it's iterating over the collection . . .
you'd get an error . . .
It depends on the context it's used in. | can be either a non-short-circuting or comparison or a bitwise OR operation depending on whether you're trying to use it where it expects a bool or an int
then something is wrong with my code💀
really wrong
cuz I got not error
I did something like this in a project. You can make a function that is a foreach loop and restart that function with the new array as an input, but it needs a fail condition so it doesn't infinietly loop
oh Ik whats wrong
you have to show your !code. at this point, we have no idea 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.
yah I will its rll rll big piece of code
I mean not big
badly written
i always use for loops bc it's easy to modify, change, stop, and start based on a condition . . .
i never use for loops
yeah for loops are the best
Banned
my first issue is the paramater n for the shootHitScan method. it does not explain what it is used for or supposed to do . . .
n is if I have more then one firepoint
No errors means the code is doing exactly what you told it to do. This says nothing about whether or not you've told it to do the right thing
okay, cuz i have to search for n within the code, then read where it's used to figure out what it's suppose to be . . .
well it is doing it right, just not going what I want it to do
I still don't know what the purpose of this code is
I'll show u
No you just aren't generating runtime errors or syntax errors
Code doesn't know what you want, just what you've told it
this is really wierd, it is doing the if when it got to 14/15 instead of 2
this is good start though. it sure is better than no code . . .
this is what it does
it was working good I just want to be able to change a variable if I want the weapon to bounce the shot
yah thats true
That's a really complicated way to write 15
yah I know but to put it in other words, I dont know what do tell the code
like you want to run this again for the bullet if it can bounce?
why not just check if it's 15 instead of doing all that bitwise math?
exactly
im not trying to write 15, i was tryna do 2 OR 7 OR 11
but starting from the pos of the wall to the next wall
also another thing that is not related do raycasts rotate according to the object rotation?
Well, right now you're doing a bitwise comparison of three numbers
like if they were children of the object
isnt it || for or?
Use ||
I think you could have chopped this function into smaller functions to do this so that reusing some logic would be easier
| can be, but I think issues occur when you use it on ints
| doesn't shortcircuit, and || does when used as an or
i did that at first but it said
I will definitly do that after fixing this issue💀
Yes because "Yes or no: 2 or 7" doesn't make sense
what does | do
It would help you fix this issue
Bitwise OR operator
it makes sence to me
damn
So, tell me yes or no to this question:
32 or 17?
yes
You could technically restart this function if the the bullet is able to bounce, if there is a max bounce count you woul also subtract from that
I guess you are right
And how did you decide that? Or just trolling?
Gotta show your work
Why
nah but it isnt yes or no, it is checking a number ( for example 8) and seeing if it is the same as 2 Or 5 Or 7
good idea tho
It is a yes or no though
That's what a Boolean is
do yk the answer to this? might be handy later
|| compares to booleans and returns a boolean
what if i wanna compare 2 int
you can assign whatever direction you give the ray
Compare how? What comparison do you want to provide between two numbers?
You want to do
int num = //rounded time
(num == 2) || (num == 7) || (num == 11)
ok i remember from school how its a boolean now, and i see how im supposed to do it above
if you did in 2D var ray = new Ray (transform.position , transform.right)
if u rotate said object then the ray is rotating with object sure
thanks everyonme
ah ok, makes sence ig
More like aeth gave you the code finally and now you have your answer until the next time you don't understand c# syntax
i rest my case
yea pretty much, not sure how else i could solve it without someone telling me
You can keep doing this forever, or you can just take some time to learn the language
Sorry guys... 😭 lol
I'm not going to help you if you refuse to help yourself
I do it all the time to
You could try actually reading the page I linked that shows how to write c#
where?
You don't seem to understand types or functions. You're treating numbers and booleans as if they're interchangeable
It's the intro to c# guide in the pins
In fairness that is not the most appetizing thing to do. At the very least they need a youtube vid or some sort of informative content about CS to consume
Best to do these kind of courses multiple times imo
thats exactly what I did actually
good to know
if (number is 2 or 7 or 11) // :)

Yeah, I always try to keep my suggestions as similar as possible to what the person gave lol, just corrected
Yeah, I gotcha
i forgot about this syntax
i feel like ik most of thise tbh
anyone know what would set a kinematic rigidbody2D 's velocity to zero?
Do you know it or can you recognize it
kinematic has no velocity
You need to actually internalize what it means not just "Yeah that looks right"
rigidbody.velocity = new Vector2();
Setting it to kinematic sets the velocity to zero afaik ah only for 3d ones nvm
let me be blunt: you don't
2D rigidbodies do have velocity
that is fine
I don't think so.
it is acceptable to not understand things
thats what makes them Kinematic afaik
well there is like 500 subheadings so it will take me ages to check if i know each one
they do in 2D
you are approaching this completely wrongly. you are not going to read 500 paragraphs to learn 500 little concepts and then "know C#"
how not>
Follow some of the introductory tutorials. Get through the tutorial, then play around with the code you've written.
is this tutorial fine compared to the other ones people said, https://www.w3schools.com/cs/cs_methods.php
I mean, that's just methods
yea it has all the stuff that is just the last one i clicked on
That is just C#, there would not be any Unity nuance
someone else said to follow a couse and linked one without unity as well so its pretty much same
The one they were linked to was the microsoft c# course. So that would also have no unity "nuance"
But yeah, @bitter carbon learn.unity.com has a junior programmer pathway
yes because learning C# you will know how to read unity's API
i agreee
i dont like that as i find it confusing where to go after ive done a section and i find it hard to navigate through which bit i wanna learn
That's why the PATHWAYS are best. They're different from just the standalone courses
And don't skip around for what you want to learn. Just do it all
Did you read #854851968446365696 before posting here?
This is unanswerable as stated in #💻┃unity-talk
As they said
https://dontasktoask.com/
provide your !code and which part does not work . . .
📃 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.
Well, considering the information provided, my guess is missing a semicolon on line 12
I think it's on line 13
Gonna give y'all the code okay okay
Those are the codes: https://hatebin.com/qcwodiyvio
https://hatebin.com/iuyctfpbec
And what is the problem
MaxHealth = -amount; in DecreaseeHealth I am supposing
The problem is that the Damage system doesn't quite work, meaning that it should every time i touch the object with the damage script it should decrease the health but it doesn't
Gonna check it
What is happening that is not supposed to be happening,
or what is not happening but is supposed to be
The second one
Well your note is in place but still doesn't work
So what is not happening but is supposed to be
Yeah
Wdym my note
That's not a yes or no question
Okay yes what is not happening is supposed to happen
Put a debug in the OnCollision and OnTrigger methods to see if you receive those messages
Again
Did you change MaxHealth = -amount; to MaxHealth -= amount;
They are asking WHAT is supposed to happen
"What" cannot be responded to with "yes"
that you are expecting to happen
What is supposed to happen is maxhealth gets decreaseed by the damage
Hello guys. How can I get the same behaviour as in "GetAxis("Horizontal")" with the new input system?
I don't want it to jump instantly from 0 to 1 and -1 but rather to go smoothly.
I change it that what's i meant with note
Do this
#💻┃code-beginner message
Are you getting logs
Changed it to what?
No
-=
Then it would seem that whatever object has the Damage script on it is never colliding with something that has a PlayerHealth component
I don't believe the input system will directly smooth inputs for you.
You can use MoveTowards to move your current value towards the input value.
Nm, yeah there is
Will do
Yes i think your right
Thank you
Did it but still doesn't work
Then no collision is happening
Does the player have a rigid body and a collider
And does enemy have a collider
Show the inspectors of the Enemy and the PlayerHealth objects
The player has a character controller not rigidbody
…
What is it?
CharacterControllers do not use OnCollision methods. They have their own:
https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnControllerColliderHit.html
Yeah was gonna reference that
Oh thank you so much!
I am a fucking dumbass
Character controllers can absolutely cause OnTriggerEnter to execute. I just checked.
A character controller that moves into a trigger collider will receive an OnTriggerEnter
So it should work?
Yes, it does triggers, but not OnCollision
I do not receive OnCollisionEnter, though.
A solid collider will fire OnControllerColliderHit instead
yep, that seems consistent
I mean, is the collider a trigger?
You had both methods, so it was unclear what type of collider it was
I'm so confused by my physics engine. I just can't move my kinematic RBs unless I set their velocity. MovePosition just doesn't seem to move them to a given position
2D, so velocity does matter
I can MovePosition(Vector2.one) to avoid any calculation issues, but the line gets called, and the body doesn't move
are you moving it a) far, b) in update, c) repeatedly in the same fixedupdate interval?
Hello guys, I have a simple question....
How to get this everytime I enter
But not this
https://hatebin.com/kdfephunrd this is the new code is it right now?
I tried moving far (like 50 units, and the body is 1x1). I move it at the end of FixedUpdate in a script with -200 priority, so it should execute last in frame.
I really didn't want to open the screen snip
Because fiddling with a cell phone and lining up a shot is so much easier than Win+Shift+S
fyi, my rigidbodies are kinematic Rigidbody2D
they can have velocity AND moveposition. It works if I change their velocity, but I don't think it is right.
your move will only take place on the next fixed update, so if you for some reason perform calculation on it before that happens it wont work
Win shift S quality not much good sometimes
And I was talking about the curly brackets
what
you should not touch both, that cant work
you're overriding one with the other
I see. well, kinetic rigidbodies do have a .velocity assigned
just DONT use velocity AND MovePos when you have a kinematic rb
ok, I'll test that out
I tried setting the velocity to zero, to allow the moveposition to go unencumbered, but that does not work
....??
I am trying to figure out how to tell the system "I know exactly where I'm going. just go there."
do you want to trigger colliders on the way?
I am making a system for that. first I need to just get things moving
Google how to change your ide settings so curly brackets stay on the same line
you arent really helping with your answers
if you don't want collisions, ie you want to teleport, set the rb position directly
if you want to have collisions, use MovePosition with a delta that is relatively small
I'm not worried about collisions right now
MovePosition will calculate the velocity to get to the destination in 1 update, if you ALSO set velocity, you will override whatever MovePosition has calculated
assume I will deal with collisions later. I am right now trying to get the body to move in a vacuum
transform.position = Vector3.MoveTowards();
I'm not moving transform
that will actively screw with what I'm doing. I need to move the RB
why dont u use MovePosition like mentionedbefore
I'm trying but the system is confused because .velocity was screwed with
I think I need to refactor the way anikki mentioned
so .velocity never gets touched. I wish I could just make 2D kinematic RBs not use their velocity in simulation
then you can't have collision interpolation
you can't have physics and not have physics at the same time
I will take care of collisions myself
I just want the physics system to generate contacts at the end
then just move the freaking transform
I'm making a physics engine to figure out the in-betweeen
Oh yes!, I'll check the settings. Thank you
assume I can calculate the target destination accurately
{
"FormattingOptions": {
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInAnonymousTypes": false,
"NewLinesForBracesInControlBlocks": false,
"NewLinesForBracesInTypes": false,
"NewLinesForBracesInMethods": false,
"NewLinesForBracesInProperties": false,
"NewLinesForBracesInObjectCollectionArrayInitializers": false,
"NewLinesForBracesInAccessors": false,
"NewLineForElse": false,
"NewLineForCatch": false,
"NewLineForFinally": false
}
}
create an omnisharp.json file in the root of your project
also, I do not know if assigning rigidbody.position is a problem
for the middle of a calculation, I basically want to teleport an RB around, then teleport it back to where it started when I'm done.
Hey! How can I rotate an object from its center? I used this but this will rotate it by the pivot:
transform.parent.eulerAngles += new Vector3(0, rot, 0);
how
ok, it seems like MovePosition overwrites anything going on with velocity
my hitscan reflection isnt working properly💀
private void OnEnable() {
playerInputActions.Player.Jump.Enable();
playerInputActions.Player.Jump.performed += DoJump;
playerInputActions.Player.Movement.Enable();
playerInputActions.Player.Movement.started += DoMove;
playerInputActions.Player.Movement.canceled -= DoMove;
}
private void DoMove(InputAction.CallbackContext context)
{
hzInput = playerInputActions.Player.Movement.ReadValue<float>();
rb.velocity = new Vector3(hzInput * speed, rb.velocity.y, 0);
}
Should the movement logic be in a fixedupdate instead ;-?
Right now if i tap the left button it just keeps walking towards that direction. I suppose that's because .canceled -= DoMove; is not the right way to do it.
I think this is ok
the .canceled is wrong
-= removes the function from getting called
it does not make the function do the opposite
Hm, then how could I make the function get called only when the "left"/"right" button is pressed.
Hey! How can I rotate an object from its center? I used this but this will rotate it by the pivot:
transform.parent.eulerAngles += new Vector3(0, rot, 0);
releasing tap isn't canceled. it is performed
you should subscribe functions for .started, .performed, and .canceled
RotateAround iirc you can specify a specific point
https://docs.unity3d.com/ScriptReference/Transform.RotateAround.html
canceled would be something like: you were holding a button, and tabbed out. the program had the input actually interrupted
OR it got canceled because a different type of callback is going (e.g. long press will cancel the tap interaction)
so i should just change the .canceled to .performed?
transform.RotateAround(transform.parent.position, Vector3.up,rot);
Still rotating around pivot
you need both
if tap gets canceled by tabbing out, you also want to register it as letting go
RotateAround rotates around whatever point you pass in as the center
else the program will keep the player moving while tabbed out
So what i would want to do is to remove the function from getting called on the .performed and .canceled event and add it on .started ?
Add the function to being called from all 3
it is reading the value in the function anyway
Oh, so I have to do this. Isn't there any option in settings ?
Wait, what IDE are you using?
is that input a control stick actually?
nope, keyboard key
VS code
nvm then. ok
transform.parent.eulerAngles += new Vector3(0, rot, 0);
Okay but still it is rotating incorrectly. RotateAround still doesnt work
i think it is the only option
Using your code for making this setting ?
Yep
Okay
perhaps this as well
aren't you passing the pivot as point to rotate around?
I do, but how to fix it?
A. would be easier to just fix the pivot in blender.
B. you could just pass the collider/bounding box as the center
How to do B?
I recommend you only set a Vector3 in your InputAction method and then in FixedUpdate() you set your velocity to that Vector. You can use: if (context.canceled) movementVec = Vector3.zero;
to stop moving.
.center prop
iirc you can also get it from the mesh/renderer if you have no collider
Oh god it works!
Thanks!
Also, how can I make the cursor is on the center of the transform?
Now I am just setting the pivot's position where the cursor looks:
BuildingGhost.Instance.transform.localPosition = raycastHit.point;
Can you help for a minute please? ^
sure but not sure I understand wdym the cursor? is it a gameobject
Let me show you
Will look into it, thanks
Here you'll see that the cursor is on the pivot of the gameobject, not on the center where its rotating.
the best thing to do here is using proper pivots
Sure, bot how?
basically you make a new child object place it where you wuld want pivot to be then reverse the order, make the parent now the child of this object. obv put this object outside the parent first
Also, any other options avalailbe if possible? Because the buildingghost gameobject can be various and their pivots can be different
I mean you could also just do the same thing you do as your rotatearound
Yeah but that is a vector3 and not a transform
the parameter is a vector3
Yes, so I should set the BuildingGhost's position to the cursor's position as there is now, and then use that Vector3?
ehh actually I think you would need to do some math and get the offset
then put that in the follow transform for the ghost
Hey guys quick question. How can i make it so when i impact against a certain object a certain sound effect comes out?
what follow?:
play a sound when the impact occurs . . .
doesn't your ghost transform.position goes to mouse hit ray
Ah sure
Sorry for bothering you this much, what kind of math should I use here?
So like I'm completely dumb
Use the center I assume
Im unsure on how to, or rather i dont know how to. Maybe i should make a "If player touches x item it calls a sound"? or something like that?
probably something to do with seeing how far pivot.position is (transform.position) vs bounds.center.
that should be your offset
yes, try and break it down into tasks:
- first, you need to check for an impact (collision)
- second, you need to check what the collided object is
- third, you need to play the sound effect . . .
So (transform.position - bounds.center) is my pivot
I should use tags for that right? i believe the answer is yes.
And then BuildingGhost.transform.position + offset = cursorPos
anyone know how i can make it so there is around 40 different things in here, but in a different way as it will be very untidy and worsen performance if i write them all out
like maybe some sort of maths pattern
also, each of these tasks can have their own list of tasks as well. you can use tags; that's one option to check for the collided object . . .
Alrighty, i think i know how to make it work
you shouldn't have to check for 40+ different results. what are you trying to do?
if you have that many, place all the numbers in a list, then iterate the list and check the current index (iteration) . . .
i just want it so every x seconds passes since the game started it does something in the if but its gotta slowly be in lower increments
i asked chat gpt but i think ur method is better🤣🤣
then you should only have to check one variable. when the first value is passed, increment it by a certain amount, then you check against the same variable but it will have the new value . . .
that isnt what i want
yes it is
maybe i explained what i was tryna do wrong or smth but this isnt it
Well, first off, why not say what "this" even is, as you understand it
Explain what you want to make your game do
not "check these 40 numbers"
What gameplay are you creating?
so ill probably end up doing in a list but
A timer that goes off more often as the game goes on?
yes, exactly
i'd just use an animation curve that changes the value of the variable and you check that against your time . . .
In that case,
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/arithmetic-operators#remainder-operator-
Okay, that sounds reasonable, but please humor me here -- I want to know what gameplay you want to create.
does it matter?
I don't ask irrelevant questions.
Yeah, it's called an XY problem at this point.
i dotn reeally wanna explain if it doesnt matter so can u say why its impirtant
Asking about your attempted solution rather than your actual problem
Asking about your original goal, rather than whatever solution you attempted, will help people help you.
private void DoMove(InputAction.CallbackContext context)
{
hzInput = playerInputActions.Player.Movement.ReadValue<float>();
rb.velocity = new Vector3(hzInput * speed, rb.velocity.y, 0);
}
private void FixedUpdate() {
CharacterRotate();
Debug.Log(rb.velocity);
Debug.Log("hzInput: " + hzInput);
Debug.Log("speed: " + speed);
}
Seems like my velocity on the X axis slowly decreses the longer I hold a button pressed down. ;-?
Is it because I'm not running the movement logic inside a fixedUpdate method?
there can be an easier way to perform what you're asking if they have an idea on what system/mechanic you're trying to make. just bc you don't think it's important does not mean it isn't . . .
idk how to make it cleaer tbh, but ig ill explain what the game will be like
DoMove gets called every time the input updates, iirc
So it only gets called once. verify with a log statement.
I prefer to use InputActionReference to get values. It makes things super easy.
public InputActionReference someAction;
...
someAction.action.ReadValue<float>();
I just read the value every frame and use it directly
DoMove is called once when your input changes. Once it stops changing, it stops resetting back to hzInput * speed and drag will slowly slow it down to 0
why do you have the method with a InputAction.CallbackContext if you're not using it and just reading the value from the action? that can be done in Update . . .
so, there is a timer that starts when the game starts,it goes up in seconds
every x amount of seconds it needs to give a message to a plant in my game so the plant will know when to develop/grow
this x amount of seconds needs to decrease the incrimenting over time so it makes the game harder, otherwise it could go on forever
i made a typo so reread before reply
How do you intend to decrease x as time goes on
wow, cool.. thanks for remembering lol!
here^^
Like, what is the actual math you intend to use to decrease x by
well i was gunna just manually type it so i wanted to know how best to store it but i might think of a formula to do it i havent decided asi dotn nkow lal the options, for exmaple there might be a built in thing that already achieves this
Oh okey, thank you
oof
ummmm^^ MODS
<@&502884371011731486>
pathetic
bah
Sorry @queen adder you're cool but your name is too close to <@&502884371011731486>
why are there no mods?
Why not just every time the timer goes off reduce by a bit
so edgy hiding behind a screen
ok its gone
That would be a linear reduction though
yeah, they need a formula . . .
You could use a formula
Edit: ah, as random said
i would do it like that but sometimes its gotta stay the same
yea
Make a method to change the x, and if a condition is met, don't change it
And then, once you have x, oh hey look its our friend that thing I said
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/arithmetic-operators#remainder-operator-
like maybe so it decreases the incrementation each time by 0.3 then rounds it
ima think about it in paint rq
why is this happeing ?
the foot moves how is supposed to when i'm not adding the height offset
im referencing a public static bool from a helper script, but it says that the helper script doesnt contain a definition for that referenced bool public static class TargetInfo { public static bool isTargetInRange(Vector3 rayPosition, Vector3 rayDirection, outRaycastHit Hitinfo, float range, LayermMask mask); { return (Physics.Raycast(rayPosition, rayDirection, out Hitinfo, range, mask)) } } bool referenced
{
RaycastHit hitInfo;
if(TargetInfo.isTargetInRange(cam.transform.position, cam.transform.forward, out hitInfo, hardpointRange, shootableMask))
{
//create laser hit particles
foreach(var laser in lasers)
{
Vector3 localHitPosition = laser.transform.InverseTransformPoint(hitInfo.point);
laser.gameObject.SetActive(true);
laser.SetPosition(1, localHitPosition);
}
}``` where its being referenced
If the ray hits nothing that's gonna move this object to 0,0,0 in world space
What is the specific error
but the ray allways hits something
Assets\Scripts\LightCruiser.cs(117,23): error CS0117: 'TargetInfo' does not contain a definition for 'isTargetInRange'
is it in a namespace or a different assembly?
i think smth like this
; at end of method definition
This function has no declaration
There's nothing in it
damn, good eye . . .
yea i forgot to save that, now i got 10 errors instaed of 1 💀
Which are?
is your IDE even configured ?
Yeah there's quite a bit of syntax errors. Look at the stuff underlined in red, you're probably missing something
i followed the guide to configure it and nothing changed.
using vscode
no "ide" stuff works
if nothing is underlining red you did not configured it
What version of the Visual Studio Editor package in unity do you have?
all three are installed
this aint the only step
What does the External Tools menu look like in Unity
ah so you skimmed thru it
Too old
digihlic the ray walyas hits something, this occurs only if i add the offset, i don't see why it won't move
like everyone else
Remove the Engineering package
Then you can update it
Needs to be 2.0.20 at least
Also, you do not need the Visual Studio Code Editor package. It may cause problems
Both IDEs use Visual Studio Editor
First just do what I said. That is likely the part that got messed up
It looks like it's moving to me in the video? You move up and down and it stays in place. You move it sideways and the ray moves with it
how do you make a brodcast audio/measage like recroom does when its going under maintnence
dont crosspost
are negative decimals always double or can u make it a float
Do you mean play a sound?
it wont let me remove vs code editor lol
-0.5f
dafuq is recroom?
k thanks
that's my problem, when i add the height offset is moves only up and down, i need it to move also left right and forward
Remove the Engineering package first, as I said
search recroom going under maintnecne
no
put some type of effort into your questions..
If you want an offset in multiple directions, add a whole vector rather than up times a constant
well i'm adding the vector
You're adding a vector that is pointing straight up
If you want offset in other directions, you're gonna need a vector that is in that direction
switch to the "Unity Registry" category, then remove the "Engineering" feature
transform.position = footPosition + new Vector3(footPosition.x, footPosition.y * heighOffset, footPosition.z);```
like this ?
this does not make sense
it would add more and more height as you get further vertically from the origin
Why are you doubling the X and Z position of the vector?
how do you make a measage/audio that plays in every server so kinda like
New Update In 10m
Then 5m past then it say
New Update in 5m
Then after the timer is up
Servers get closed or everyones game quits and cant play until servers update
just...play a sound?
This depends entirely on what you mean by "server"
But it also sounds like you just want to play a sound
transform.position = footPosition + new Vector3(0, footPosition.y * heighOffset, 0);``` this ?
every person in the game can hear
that does not answer digi's question at all
but how will they hear/see it
i got the same result
Take a moment and think about it
Position is where the foot is
well, I guess it kind of does
footPosition is where the ray hits
but I don't know how your multiplayer architecture works here
Break the problem down.
How do I make a message/audio
How do I delay something
The whole point is you need way more details ❤️
send an RPC
how
anyone know why this doesnt work
because this is bogus syntax
Tell me, in words, where you want the foot to end up relative to where the ray hits the ground
explain?
What are you even trying to do there
where it hit
what do you think that is supposed to be doing?
Then... you don't want an offset at all?
Servers can invoke a ClientRpc to execute on all clients.
So just use footPosition
only on the y aixs
Then you're good
You're currently adding an offset on the Y axis to where the ray hits
Third argument is for counter increments and decrements not random arithmetics
but i got the same result
the foot only moves on the y and not on the x and z
The result that seems to be what you just said you wanted
specifically, it's for complete statements
ok that is what it was siuppoised to be
it's not
It doesn't move on X or Z. It always ends up exactly where the ray hits
yes j = 9
Wth is j -0.6f
j = 9
what?
You have no = sign though oh misread. So that says 9 -0.6f which is different than 9 - 0.6f btw
And that doesn't make much sense there either
wait lemme think
whats 9 -0.6 mean
something like
Play Audio : 10 minutes until next update
Delay 5 minutes
After Delay: 5 minutes until next update
Delay 4 minutes
After Delay: 1 minute until next update
Delay 1 minutes
After Delay: Kick Everyone From Game To There Meta Home,
Disable servers for (How Much Time)
wdym
not C# Code btw
More like: What does it mean to check if 9 - 0.6 every frame
you said j is 9
so what is 9 -0.6
its simple maths my brain cannot explain it more
That just lists two numbers
digiholic, i want the foot to stay in place and to add an height offset to it, when i add the offset the foot stays in the right position only when moveing up and down, look again in the vid
If you placed i + 3 - z / x you'd still get an error. These aren't statements. Invalid mumbo jumbo.
yea
did not help
so what operation are you trying to do ?
It is not math. It is two numbers next to each other
You are casting a ray straight down from where the foot is, then moving the foot to the place that ray hits, plus some height offset
Is that what you want?
that can be math u know
Math is procedure
Not without an operator.
Digi said it better
Two numbers standing next to each other is just a pair of numbers
I'm not seeing what y'all are seeing. that is a valid expression
We don't know anything about your system. Google how to make a message or audio.
it's just that you need a statement there
Please go google what a for loop looks like and compare it to what you have instead of confusing everyone with dumb math
This is my script which is attached to a moving blue ball. I want it to cast projections as shown in the photo (black cylinders of S(0.02f,len,0.02f) ). I am trying to do something of that sort in the for loop line 39-50. But there seems to be some problem with my math.
This is a college assignment & we are not allowed to use raycasts to do our projections, but rather just pure vector math. Can someone please help me out? @slender nymph or anyone?
TravellingBalls.cs : https://pastebin.com/HPT09Y7U
Reference Script from Github: https://github.dev/Apress/basic-math-for-game-dev-w-unity3d/blob/master/Chapter-6-Examples/Assets/EX_6_4_MyScript.cs
it is same
already did but bing just says
NOOO, i want know why the food dosen't stay in place when i add the height offset, but it moves when i don't add the height offset
No it's not
I promise you it is not which is why you have an error
ok ill be afk for a bit
this needs to go in a thread if it continues
don't ping people into your questions
also wtf. why ping me specifically?
cuz you were the only one who helped me last time (twice)
It is against the rules to ping people you aren't currently in conversation with
What happened last time is irrelevant
alright, I didn't know. I'm sorry, wont do this again
The reason it worked in the first place is the thing I said originally. Your ray hits nothing, so it goes to 0,0,0. You're raycasting down from the foot, and when the foot is below the ground the ray hits nothing
// Expression statement (assignment).
area = 3.14 * (radius * radius);
// Error. Not statement because no assignment:
//circ * 2;``` @bitter carbon
So, when you add height, the ray actually hits the ground
and therefore moves the foot to the ray's position
can anyone help me out here? really stuck badly 😢
ah thanks, was confused.
my unitys been loading for 15 min💀💀
how can i restart my pc without losing my work
you probably have an infinite loop
me?
what would make you think that was in reference to your issue?
nah my pc just bad, i // my loop code which wasnt even infinite and its still going
@sturdy lintel Not seeing a single debug message in your code. Debug what's happening and understand the problem. https://unity.huh.how/debugging
nah, you 100% have an infinite loop somewhere.
most likely in some object's Awake or Start method
An infinite loop would definitely cause it to hang though
something wrong with my math. I'll add debuglogs
no need to tell me that
