Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | lowy98 |
Hey , I am new to programming, and i am “trying” to make a top down game where i can click on the player and make him move, anyway I have a Raycast2d and i want the player to move backwards (whatever the player’s direction is (btw i am using look_at()) when ever RayCast collides with something,Automatically btw, using lerp or something like that…
if $RAYCAST.is_colliding():
lerp(global_position,....)
(Remember i am a complete Beginner I just started)
Not sure if I can follow… You want to make the player character clickable and make it move backwards (i.e. invert it’s movement direction?) once it has been clicked. And you want to move the character (Is it a KinematicBody2D? A RigidBody2D? Something else?) using linear interpolation (that’s what lerp stands for) as long as the RayCast2D attached to this character (Pointing in which direction? Being how long?) is colliding with anything (Or something particular?). Now where is that automatic, if it’s triggered by the player clicking on the character? And what exactly is your question here?
njamster | 2020-05-11 13:46
Sorry for the delay, alot to do and no time left , Ye I want and I already made (copied the code ofc from gdquest (starpath) https://www.youtube.com/watch?v=Ad6Us73smNs , as you may be thinking I did not Understand most of the code if not all of it), I can click on him (KinematicBody2D) and move him where ever I want (depends on the mape size and i want the player to dodge or … move backward when the raycast collides with the enemy (with a speed lower than the enemy ofc) as long as the player is facing the enemy and as long as raycast2d is colliding (and after i activate it using a button but anyway), wow after typing this this seems complicated than i thought, ye and all that by himself , i want the player to do this, ik this is too far for a beginner but … and also I am making another game at the same time and it’s a strategy game 2d where you can summon your own troops and watch them fight against the Enemy (the Enemy is just the bot… for now) but i have a problem, lets say I have a range troop that has area as range for his arrow, he’s doing fine but when there is more than 1 enemy in the range area or when he reaches the base of the enemy he detect the first enemy and then act like there is no other bodies in his range, i know what the problem is, I use a boolean Body_entered and Body_exited, when the body exited the boolean change to false but at the same time there is a body in the area but the boolean is already set to false because of the last body that exited the area… what the solution in your opinion?
Thanks
lowy98 | 2020-05-13 07:41