Hello i am stuck again with this simple code, there is error:
Assets\shooting.cs(25,26): error CS0103: The name ‘bullet’ does not exist in the current context
and
Assets\shooting.cs(24,9): error CS0118: ‘GameObject’ is a type but is used like a variable
please help
In line 24 you just say “GameObject =” you are missing your name; ‘GameObject gameObject =’. But then it would only exist locally and your reference would be gone once the function ends. Declare GameObject gameObject in the class outside of a function then set ‘gameObject =’.
Line 25 just says bullet and I see no reference to a bullet.
Ok but i am trying to learn form yt and i just copied everthing what he does so why it is not working for me and working for him?
“Ok but i am trying to learn form yt and i just copied everthing what he does so why it is not working for me and working for him?”
You haven’t copied the code completely… in your code: GameObject = Instantiate...
(like already mentioned by @adehm ) and in the tutorial video it says: GameObject bullet = Instantiate(bulletPrefab...
You can’t have a type alone like that, as in the tutorial GameObject bullet means author creates a variable named “bullet” that is of type GameObject and then he Instantiates a prefab and it then gets assigned into this variable.
Thank you guys, that was so simple, idk why i didnt see that