How to fix this?

Whats the value of “increase_amount”?
And actually change the code a bit:

func _ready():
    ...
    connect("body_entered", self, "body_collided")

func body_collided(body):
        speed += increase_amount 

func _physics_process(delta):
       var linear_velocity = velocity
	if linear_velocity.length() < speed * delta:
		linear_velocity = linear_velocity.normalized * speed * delta

And set the property “contact_monitor” to true

1 Like

okay, i added to body collided print(“Collided”) but there is nothing in the console
and my value of “increase_amount” is 10 and there is no errors at this time.

— Debugging process started —
Godot Engine v3.5.3.stable.official.6c814135b - https://godotengine.org
OpenGL ES 3.0 Renderer: GeForce GTX 550 Ti/PCIe/SSE2
Async. shader compilation: OFF

colided
600
entered
colided
700
entered
colided
800
entered
colided
900
entered
colided
1000
entered
colided
1100
entered
— Debugging process stopped —
My ball must move very fast but its like turtle and then even stops, i want to move my ball all the time but after colliding just increase the speed to be not to easy for player.

Hm yeah the kinematicbody2d is actually better for this usecase. Heres something from the docs:

extends KinematicBody2D

var speed = 750
var velocity = Vector2()

func start(pos, dir):
    rotation = dir
    position = pos
    velocity = Vector2(speed, 0).rotated(rotation)

func _physics_process(delta):
    var collision = move_and_collide(velocity * delta)
    if collision:
        velocity = velocity.bounce(collision.normal)
        if collision.collider.has_method("hit"):
            collision.collider.hit()

Then you still need to increase the speed when you collide with a paw

But now i cant change it, i have already made a score system and i dont know will it work if i change?or it will be not too hard to change?

what does the score system count?

func _on_YarnMouse_body_entered(body):
	print("entered")
	if body.is_in_group("Paws"):
		emit_signal("score_increment")
		print("paws detected")
extends Node2D

var score = 0
onready var score_label = $Timer # Make sure to set the path to your score label node

func _ready():
	var yarn_mouse = $YarnMouse  # Adjust the path to your YarnMouse node
	yarn_mouse.connect("score_increment", self, "_on_score_increment")

func _on_score_increment():
	score += 1
	score_label.text = str(score)
	print("score is added")

it countes my paw and ball colision

Yes should be pretty easy to change


var speed = 750
var increase_amount = 10
var velocity = Vector2()
var collided = false

signal score_increment

func start(pos, dir):
    rotation = dir
    position = pos
    velocity = Vector2(speed, 0).rotated(rotation)

func _physics_process(delta):
    var collision = move_and_collide(velocity * delta)
    if collision:
        velocity = velocity.bounce(collision.normal)
        if collision.collider.is_in_group("Paws") and not collided:
            print("Collided with Paw")
            emit_signal("score_increment")
            speed += increase_amount
            velocity = Vector2(speed, 0).rotated(rotation)
            collided = true
    else:
        collided = false

This should do the same

okay, the score system will stay the same yes ?

yes you just have to emit the signal as shown in code

EDIT: updated the code just now to fix some stuff

Thanks, i will try soon.

my mouse isnt moving

OK, i fixed that, but now we return to the same problem that was at first

and that is?

that sticks my ball to my paw but i think i fixed that


i increase my safe margin from 0.08 to 2(anyway i dont know what that do just happy that worked :sweat_smile:)Thank you very much for helping ! :+1: :+1: :+1:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.