What's the best way to draw a line between two moving objects?

VID_20210419_215058(0) 00_00_00-00_00_30~3

Like this, I made this using cc.Graphics - clear() the line drawn and draw a new line every frame, but it keeps flashing which not looks good. Is there a better way to do something like this?

what about using a raycast? It’s hard to tell from the video if you are trying to use physics

Sorry, I am new to Cocos, I just read document about raycast, and it seems it’s used in Vec3 and used to check intersection with raycast? Is this gonna work in cocos 2.x version?

what version are you actually using? If you are new to Cocos2d-x you should definitely use newer than 2.x. Did you mean to say that you are using Cocos Creator and not cocos2d-x?

Oh yes, I am using Cocos Creator 2.4.4

Thanks for updating the category.

Can you give me some example about the raycast with two moving object