Topic was automatically imported from the old Question2Answer platform.
Asked By
kooczsi
The error is at “else:”, I don’t know why this error suddenly came? It wasn’t there earlier and I haven’t changed anything
Feel free to ask questions about the code, if it’s hard to read
if Input.is_action_pressed("fire"):
if head.rotation.x < 1.55:
if isAiming == false:
head.rotation.x += 0.005
else:
head.rotation.x += 0.001
if not anim_player.is_playing():
if raycast.is_colliding():
var target = raycast.get_collider()
if target.is_in_group("Enemy"):
target.health -= (damage *
anim_player.play("AssaultFire")
else:
anim_player.stop()
there should be something after the * and a closing bracket, try changing it to this to see if the error goes away
target.health -= (damage * 1)
thank you too, i dont know how that even happened
kooczsi | 2022-11-28 08:51
@Gluon that part is okay. When you have the brackets (), you can split your code into multiple lines and it will execute without errors. However, without the brackets, you need to use \ at the end of the line or it will not work.
OK
var total_damage = (50 *
self.strength)
OK
var total_damage = 50 * \
self.strength
NOT OK
var total_damage = 50 *
self.strength
Juxxec | 2022-11-29 11:12
That part is not okay. You cannot mulitply by an animation play function and even if you could there is a missing bracket ).
Gluon | 2022-11-29 18:22
Oh you are correct. Didn’t see that he was doing that