#Bullet going wrong way
1 messages · Page 1 of 1 (latest)
okay can you show the current code
for bullet
also can you show the spawn bullet object pivot/rotation, you only showed bullet
spawn bullet object pibot/rotation? you mean where the buller spawns from?
indeed
what about the shoot script
Debug the value make sure you're passing the correct one
also can you show video on whats happening now instead
this too
it seems the direction might be correct
its just colliding with the player
try disabling their collisions
debug
Make your log messages more meaningful. I've no clue which log corresponds to what.
Share your updated code too
Now I collapse the log messages
And the other log?
The one in set direction
Take a screenshot of the whole console tab
ah i picked playing soudn instead
I did
yes
i see that
direction still wrong for some reason but at least not getting stuck on player
i don't know why
I can't see the order of the messages like that. Disable collapse and take a screenshot of the whole console window. How many times do I have to repeat the same thing?
thats what debugging is for
Disable "collapse" in the console window...
Come on. Read the messages and follow the instructions. It's not that hard...
Hang on, let me sleep and do that tomorrow
tbh i never have done that before and don't know how
I know, and the debug have a number "1" on it
Look at your console tab/window. Do you see the "collapse" button?
I am looking at the window tab, but i see no collaps button
*console tab
Where is the console tab? Circle it in the screenshot
Great, now look closer at all the buttons in the tab
i am look at them, clear, collapse. error pause, editor
And what button was I telling you to disable?
collapse
Can you do that now?
disable on
Now scroll to the top of the log
at the top
Ok, so finally we can confirm that the the direction is set before it is applied to velocity.
Now, It seems like it's being set to 1.
Did you actually try to face left?
Where were you facing when these logs were printed?
So if direction is always 1, what does it tell us?
int direction = spriteRenderer.flipX ? -1 : 1;
Determine the direction based on player's facing
So what does it tell us about it?
even if i put -1 instead, it's still just 1 on debug.log
Where do you put -1?
it's in the video, i tested to change the 1 in private int direction to -1
Of course it wouldn't be the value that you set in the initializer, since you're debugging dir, not direction. And even if you did debug direction, it would be overriden by dir by that point.
You didn't answer my question.
to see if the spriterendered is facing the left side so the projectile is shooting to the lieft side
we always get dir == 1. What does it tell us about the sprite renderer?
I don't know how to answer that
What does this line do?
int direction = spriteRenderer.flipX ? -1 : 1;
The line int direction = spriteRenderer.flipX ? -1 : 1; uses the flipX property of the SpriteRenderer component to determine the direction in which the player is facing.
That sounds like ai generated answer
But let's assume it's not. So what value is spriteRenderer.flipX having if we are getting direction == 1?
hmmm... then... it will.. not affect the projectile's movement direction?
and won't move to the -number way?
You're not reading what I'm saying
if direction == 1, then spriteRenderer.flipX == ?
...spriteRenderer.flipX == 1?
No. What type is flipX. What values can it have?
What does this syntax do? variable ? 1 : -1
bool??
this one? then.... spriteRenderer.flipX is a bool on the spriterenderer and direction = 1 is an int?
This one:
if direction == 1, then spriteRenderer.flipX == ?
if direction == 1 then the spriteRenderer is facing right?
the value of spriteRenderer.flipX depends on which direction the player's sprite is facing at,
If spriteRenderer.flipX is set to true when the player is facing left, but if If spriteRenderer.flipX is set to flase when the player is facing right
That's incorrect. Where did you get that info from?
And that's not what I'm asking.
What I'm asking is simply if direction is 1, then what flipX is equal to?
if direction is 1 then the spriteRenderer.flipX is false since it is a bool
Okay. I'm 99% sure that was ai generated, but okay.
So what should happen if you want to get direction == -1?
flipX is a bool, and bools have true or false.
then the spriteRenderer.flipX will be true since the -number is to the left side
or since if it's changing the direction number from 1 to minus -1 instead, then that would be also false? (idk how to answer it)
The answer that I expected is simple: "for direction to be -1, flipX needs to be set to false".
So are you setting it to false anywhere?
hmm... it have int direction = spriteRenderer.flipX ? -1 : 1; and the projectile have private int direction = 1; ... so I guess no?
So what do you need to do to fix the issue?
to try change the line private int direction = 1; to something else?
no I haven't forgotten, I meant by changing the number by adding -1 to there?
something to do with int direction = spriteRenderer.flipX ? -1 : 1;?
since when i tried int direction = spriteRenderer.flipX ? 1 : -1;. it is going to the left direction but no longer to the right.
so should i change something int direction = spriteRenderer.flipX ? -1 : 1;?
No. That doesn't answer my question
direction depends on spriteRenderer.flipX. If you want direction to change, you need to change spriteRenderer.flipX.
Now. At this point I recommend you to stop your project and go learn the basics properly. Start with the beginner pathways on unity !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
that is actual what i meant, somewhere in int direction = spriteRenderer.flipX ? -1 : 1;?
No. That sentence doesn't make any sense.
idk what to answer then
You don't need to answer at this point. I already gave you the answer. But I don't think you're gonna get far with it unless you go and learn the basics.
idk how to fix that, it works for like one of the enemies, but not for the player
I wanted it to be fixed somehow
I told you how to fix it. There's nothing more I can do if you don't understand. I suggest taking the unity learn pathway. This issue should be easy to solve once you understand what you're doing.
I know that change the spriteRenderer.flipX. but idk how
That's why you should learn the basics
I just don't know why it's not working or how to fix that, it's works for the enemy with the projectile but not for the player.
and even if i try to fix it, it's just messing with the player's sprite
You'd need to share the "try fix attempt" that doesn't work if you need any further help.
why did you comment out spriteflip?
because it would just mess witht he sprite becaise I'm unable to flip to the left side
how would it mess with the sprite? it was working fine before ?
I meant the player sprite
that doesnt answer the question
why are you showing me this and how does that answer what I've asked ?
its literally commented out, ofc the sprite is staying the same..
this is when it's not commented out
again, so why did you comment it out ?
so the player sprite can flip agian
what?
also its very annoying have to extract info from you
You should at very least put some effort into what information you are providing without having to ask you a million questions that you barely give answer to it
you answer with something unrelated
look, if i keep this, then the player sprite won't flip like facing to the left way, but if I remove these, then the player sprite and face to the left side
Remove what ? what is "these"
this image, i literally mentioned there on answering the comment there
if (moveInput > 0)
{
spriteRenderer.flipX = false;
}
else if (moveInput < 0)
{
spriteRenderer.flipX = true;
}
Ok so when you have that , does it flip or not
no
it didn't worked before (I menat for just the enemy), it just works for the projectile but not the player sprite, but when I remove that, the player sprite can flip when facing left but the projectile still shooting to the right
ok because before you were using scale to flip player
so instead of passing the flipX value to Direction, you have a bool
do you not have a bool right now ? like
isFacingRight or isFacingLeft ?
use that to pass dir instead of the spriteRenderer FlipX value
int direction = playerMovementScript.isFacingLeft ? -1 : 1;
( this is an example dont directly copy, should be obvious what to do here)