The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I'm new to programming and GDscript. I have 2 kinematicbody 1 player and 1 ball I want the ball to start stationary and move when the player collides with the ball at a set velocity but I don't know how to set the ball script to do this? I think it is basic but so far haven't found anything.

Ball script:
extends KinematicBody2D

var velocity = Vector2(100, 100)

func physicsprocess(delta):
var collisioninfo = moveandcollide(velocity * delta)
if collision
velocity = velocity.bounce(collision_info.normal)

Player script:
extends KinematicBody2D

var speed = 250
var velocity = Vector2()
var use_slide = true

func getinput():
velocity = Vector2()
velocity.x += 1
if Input.isactionpressed('uileft'):
velocity.x -= 1
velocity.y += 1
if Input.isactionpressed('ui_up'):
velocity.y -= 1
velocity = velocity.normalized() * speed

func physicsprocess(delta):
if use
moveandslide(velocity * delta)

in Engine by (20 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.