#as in the direction to send bullet if

1 messages · Page 1 of 1 (latest)

dreamy quarry
#

I done messed up now ahaha. Im not really following how to do it. The way I tried to do it was

#

where moveInput is the "Horizontal" axis. Which you probably know is quite wrong

valid ermine
#

ok one sec

#

Vector3 aimDirection = destination - source

#

source is your player's position

#

destination is is the position of your aim gameobject

dreamy quarry
#

Okay and then use that instead of the vector2 part?

valid ermine
#

correct

#

you might just a Vector2 aimDirection

#

lemme know if you get it working or need more help

dreamy quarry
#

I'm trying to do it right now but I will if I mess it up ahaha. Thank you so much though:)

#

I've done Vector2 aimDirection = transform.position - player.position; and then transform.Translate(aimDirection * speed * Time.deltaTime);

valid ermine
#

does it work?

dreamy quarry
#

I can't drag and drop the player to the public Transform I've made though. I also tried with GameObject why is that? How else can I get the players position?

#

It's because I have a script for the bullet and one for the "weapon" and the script where this is in, the bullet script, is on a prefab which makes it so I can't drag the player I think

valid ermine
#

yea your player needs to be a prefab as well

#

to drag it in

dreamy quarry
#

Oh will it still recognise the player in the scene then

valid ermine
#

Not sure, you may need to make a simple script that instantiates your player at a start position

#

try it out though before you do that

#

You can also find your player many other ways

#

through a Tag

dreamy quarry
#

Now I've made this abomination ahaha

#

Again I'm sorry for being oblivious

valid ermine
#

no thats cool

#

ok can you show me bullet code and code where you instantiate

#

you are close

dreamy quarry
#

Woow I did it

valid ermine
#

THERE WE GO

dreamy quarry
#

Daamn that is soooo nice to have it working again

valid ermine
#

and i bet you learned some things along the way, you seem to have a grasp on the very basics

dreamy quarry
#

Thank you so much for your help my guy

valid ermine
#

You did most of it

#

good job

#

save
Direction = Destination - Source

Game dev uses it alot

#

actually here

#

i got a present for you

dreamy quarry
#

A present? you should be getting one

valid ermine
#

the Direction equation is top right

#

This is a cheat sheet i used to use, for common things, you can have it, add to it

dreamy quarry
#

Ahh nice cheat sheet thank you dude

valid ermine
#

yupp, good job, you CAN and do know how to problem solve

#

you did

#

did you make an extra aim gameObject on your player? One for each side

#

walk me through how you did it, it will solidify your knowledge (if you want)

dreamy quarry
#

No I actually went in to my movement script were I altered the way of flipping the character 2 hours ago. Before it rotated the players y by 180 degrees, which then made the bullets rotation also change to 180 degrees, because of my weapon script. But know it sets the scale to -1x, because it doesn't lag the character as much. But then of course the rotation didn't change, so I saved the shooting position into the movement script and rotated that by 180 degrees when ever the players scale was changed to -1x, and that ended up solving it. Don't know if it made sense and it wasn't even scripting that much ahahaha.

valid ermine
#

yupp

#

thats another way to do it

#

gj

#

many ways to solve a problem

dreamy quarry
#

Thank you for your time and help:)

valid ermine
#

np