With a ridgid body, How can I set bounce to be different on various colision surfaces?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sojan
:warning: Old Version Published before Godot 3 was released.

So basically, I have two user controlled rigid bodies that collide together with 1 bounce set on each of them. The goal of the game is to knock the other player off of a platform (a static body). Everything works fine, exept that the balls are also bouncing off of the platform with 1 bounce (not surprisingly). So is there a way to wright a script or something, that sets the bounce for a particular collision only? Such as an exeption of 0 bounce for the static body?

Hi,
I have similar design for my game as yours.
(more like hockey ball game)
May I know how do you control rigidbody2D with collision between players?
I use get_node.get_pos() to integrate position for moving, but it seems make no collision between 2 playsers if I set them both rigidbody2d in Kinematic mode.

Thanks !

orsondudley | 2016-08-23 04:49

My game is a 3d game, so I used a ridgid body node rather than a kinematic body. Just adding collision shapes does the trick. Here is the game if you want to take a closer look.
https://drive.google.com/open?id=0B7tbusHfoTBvSWp3TmNJRGlXZFU

Sojan | 2016-08-23 13:31

:bust_in_silhouette: Reply From: Cryingpants

Sure you can, there is a method called set_bounce ( float bounce ) in RIgidBody2D and 3D. You can set your bounce in body_enter signal by checking the body object included.

Thanks for the answer, but a static body does not have a contact_monitor. Does it?

Sojan | 2016-08-07 02:42

No I don’t think so, but you can attach the script to your RigidBody and maybe check for a name or if you have more objects which should set the bounce to 0 then you can stick them all to a group and check if the body is in that group.

Or maybe add Area2D on top of that StaticBody and attach script to it.

Cryingpants | 2016-08-07 08:25

Thanks, that makes sense, but I’m new to scripting, and I’m afraid I can’t pull that off (not even sure how to check for a name). Adding a 2d area on top seems interesting too. I will try to do something with the information you gave me:)

Ps. If you know of any more material or examples I can use to learn about those functions/methods, I would be much obliged. My game is 3d.

Sojan | 2016-08-07 12:44

Well I supose that you have a script attached to your RigidBody so if you connect body_enter signal to that node, then you will get a method with parameter named body. After that I would do something like this (but that all depends on your game):

func body_enter(body):
  if body.get_name() == "ground":
    set_bounce(0)

ps. If you’d like to contact me in more personal way… so we don’t have to comment here, and you can ask me whatever you want, just write me what’s your prefered way of communication and I can help you and show you some more examples perharps :slight_smile:

Cryingpants | 2016-08-07 19:44

Thanks for the refference. I will fiddle with it and see what I can get. If you want to contact me, we can eather use email or skype. My Skype name is sojanjanso, (or Sojan Janso) with the same profile picture.

Edit: it’s not working. The code works though (I tested it with an exit body trigger), but it never gets triggered on time when the collision occurs.

Sojan | 2016-08-09 13:40

Sojan,
million thanks for your reply and share of your works.

orsondudley | 2016-08-23 14:11

I want some examples in order to get an complete conllition system, with these elements:

1- Collition of rigidboody for static models of my main scene.

2- Collition for dynamic models of ambientation of my scene (like destructibles walls, glass, windows…).

3- Collition of player interacction with other NPC (bullets, life, hits, get items, inventary).

If you can helpme easely with some fast example i would be pleased.

My mail is this one: fofoman70@gmail.com

RODGIMA | 2016-08-23 21:29