|
|
|
|
Reply From: |
Zylann |
get_pos()
was replaced by the position
property:
var leftCollider = Rect2(get_node("leftplayer").position - pad_size * 0.5, padsize)
Identifier ‘pad_size’ is not declared in the current scope
Ne diyorsan onu yaptım bu hatayı alıyorum.
CarelPersonne | 2019-08-21 18:34
pad_size
has never been a built-in variable in Godot 2, it must come from your game. Check if you declared that variable.
Zylann | 2019-08-21 18:36
var padsize
func _ready():
screenSize = get_viewport_rect().size
padsize = get_node("rightplayer").get_texture().get_size()
set_process(true)
pass
Specified in this way
var padsize
padsize = get_node("rightplayer").get_texture().get_size()
CarelPersonne | 2019-08-21 18:45
It could also be that you made a typo, you wrote padsize
but the error says pad_size
.
Zylann | 2019-08-21 18:47
Yes There is one more thing I want to say correctly Rect2
var leftCollider = Rect2(get_node("leftplayer").position - pad_size * 0.5, pad_size)
There is an error in Rect2
CarelPersonne | 2019-08-21 18:51
position - pad_size * 0.5
What is the type of pad_size
? It has to be a Vector2
otherwise it won’t work.
Zylann | 2019-08-21 18:55
Code worked when pad_size
var leftCollider = Rect2(get_node("leftplayer").position - pad_size * 0.5, pad_size)
Now there is an error in Rect2
CarelPersonne | 2019-08-21 18:57
What is the error?
Zylann | 2019-08-21 19:47
var leftCollider = Rect2(get_node("leftplayer").position - pad_size * 0.5, pad_size)
var rightCollider = Rect2(get_node("rightplayer").position - pad_size * 0.5, pad_size)
if(leftCollider.has_point(get_node("Ball")) or rightCollider.has_point(get_node("Ball"))):
ballDirection.x = ballDirection.x
I get this error
İnvalid type in function ‘has_point’ in basa ‘Rect2’. Cannot convert argument 1 from Object to Vector2.
CarelPersonne | 2019-08-21 20:03
has_point(get_node("Ball"))
Godot is telling you has_point
expects a Vector2
. get_node("Ball")
is not a Vector2
, it’s a Node
. You may want to do get_node("Ball").position
instead.
Same as in A code error in Godot 3 - Archive - Godot Forum
Zylann | 2019-08-21 20:09
Thank you. Working successfully
CarelPersonne | 2019-08-21 20:32
Is there anything I can contact you at another time for help?
CarelPersonne | 2019-08-21 20:39