#Water Interacting with the player
31 messages · Page 1 of 1 (latest)
if with animations you mean the animation player, those are inherently static, so not really suitable for dynamic interaction you would need here.
seeing how your current setup looks like would be necessary to decide how to achieve it best.
okay, so shall I put my player script here?
(note: I am using a player script off a framework thats mimics 2D sonic movement)
should I?
?
also I dont quite understand this
isn't this about the water?
i mean no matter how you achieve it, if you want your water to interact when the player moves in it, that's by definition physics. It might just not use the built in physics system.
okay, I see how this is. so for example if my CharacterBody2D is in an Area2D node, I should slow the player down.
for me to slow my player down it would be:
abs(motion.x) = 10
i see, so you mean those kinds of interaction. yeah that's kinda the intenden method, as Areas already have other ways to affect objects inside of them, like changing the gravity.
giving your player some general way to let things affect its movement speed would probably make the most sense.
ok
should I use signals?
the body_entered/exited signals of areas are generally the first choice for this.
soo:
func _on_body_entered(body: CharacterBody2D):
pass
heres what I did
I cant figure this out:
func _on_body_entered(body: CharacterBody2D):
body.velocity = 1
i used 1 as a test, becuase the variables/constants in the player script cant be accessed
theres an error saying:
Error at (15, 21): Cannot assign a value of type "int" as "Vector2".
well that's the thing, velocity is the actual motion of the player, it's what you change to move it, it's not the same as the speed you use inside your player controller. that's the one you would have to change.
how can i just access my player variables?
without using global scripts
maybe i can use methods
yep I cant figure this out
the body is the player.
you are able to access self defined variables just like the ones built into the base classes you are using (like you did with body.velocity)