#Bullet going wrong way

1 messages · Page 1 of 1 (latest)

jade swift
#

okay can you show the current code

#

for bullet

#

also can you show the spawn bullet object pivot/rotation, you only showed bullet

autumn tiger
jade swift
#

indeed

jade swift
jade swift
#

also can you show video on whats happening now instead

tough elbow
#

Debug both in start and set direction

#

To see which one is called first.

jade swift
#

its just colliding with the player

#

try disabling their collisions

autumn tiger
tough elbow
# autumn tiger debug

Make your log messages more meaningful. I've no clue which log corresponds to what.

#

Share your updated code too

tough elbow
autumn tiger
tough elbow
#

And the other log?

#

The one in set direction

#

Take a screenshot of the whole console tab

autumn tiger
autumn tiger
jade swift
#

i see that

#

direction still wrong for some reason but at least not getting stuck on player

tough elbow
jade swift
tough elbow
#

Come on. Read the messages and follow the instructions. It's not that hard...

autumn tiger
autumn tiger
autumn tiger
tough elbow
autumn tiger
#

I am looking at the window tab, but i see no collaps button

tough elbow
#

Where is the console tab? Circle it in the screenshot

tough elbow
autumn tiger
#

i am look at them, clear, collapse. error pause, editor

tough elbow
#

And what button was I telling you to disable?

autumn tiger
#

collapse

tough elbow
#

Can you do that now?

autumn tiger
tough elbow
#

Now scroll to the top of the log

autumn tiger
tough elbow
#

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?

autumn tiger
tough elbow
autumn tiger
tough elbow
#

So what does it tell us about it?

autumn tiger
tough elbow
autumn tiger
tough elbow
#

You didn't answer my question.

autumn tiger
tough elbow
#

we always get dir == 1. What does it tell us about the sprite renderer?

autumn tiger
#

I don't know how to answer that

tough elbow
#

What does this line do?
int direction = spriteRenderer.flipX ? -1 : 1;

autumn tiger
#

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.

tough elbow
#

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?

autumn tiger
#

hmmm... then... it will.. not affect the projectile's movement direction?

#

and won't move to the -number way?

tough elbow
#

You're not reading what I'm saying

#

if direction == 1, then spriteRenderer.flipX == ?

autumn tiger
#

...spriteRenderer.flipX == 1?

tough elbow
#

No. What type is flipX. What values can it have?

#

What does this syntax do? variable ? 1 : -1

autumn tiger
#

bool??

tough elbow
#

yes

#

So What's the answer to the previous question?

autumn tiger
tough elbow
autumn tiger
#

if direction == 1 then the spriteRenderer is facing right?

tough elbow
#

No.

#

What value does it have?

autumn tiger
#

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

tough elbow
#

And that's not what I'm asking.

#

What I'm asking is simply if direction is 1, then what flipX is equal to?

autumn tiger
tough elbow
#

Okay. I'm 99% sure that was ai generated, but okay.

#

So what should happen if you want to get direction == -1?

autumn tiger
autumn tiger
tough elbow
#

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?

autumn tiger
#

hmm... it have int direction = spriteRenderer.flipX ? -1 : 1; and the projectile have private int direction = 1; ... so I guess no?

tough elbow
#

So what do you need to do to fix the issue?

autumn tiger
#

to try change the line private int direction = 1; to something else?

tough elbow
#

no...

#

It's like you immediately forget the conversation so far...

autumn tiger
tough elbow
#

No

#

What does the direction depend on?

autumn tiger
#

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;?

tough elbow
#

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

upper craneBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

autumn tiger
tough elbow
autumn tiger
tough elbow
#

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.

autumn tiger
tough elbow
autumn tiger
tough elbow
#

That's why you should learn the basics

autumn tiger
autumn tiger
tough elbow
#

You'd need to share the "try fix attempt" that doesn't work if you need any further help.

jade swift
autumn tiger
jade swift
autumn tiger
jade swift
#

that doesnt answer the question

jade swift
# autumn tiger

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..

autumn tiger
jade swift
autumn tiger
jade swift
#

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

autumn tiger
jade swift
#

Remove what ? what is "these"

autumn tiger
#

if (moveInput > 0)
{
spriteRenderer.flipX = false;
}
else if (moveInput < 0)
{
spriteRenderer.flipX = true;
}

jade swift
#

Ok so when you have that , does it flip or not

autumn tiger
#

no

jade swift
#

How was it workin before ?

#

when you had it working

autumn tiger
# jade swift How was it workin before ?

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

jade swift
#

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)