#Help
1 messages ยท Page 1 of 1 (latest)
That's not an issue
hait
Don't worry, just continue
see
i folow Brakys tetoril
vedio
but i tryed to chang the code by my self
the real 1
is to make the player movment fuls
but i tryed to made the obstacle an bounser
shang it to bounser
change
Ok
So you want:
- Player to collide with the SSSD game object
- Make the player bounce off the object?
i thik you mean make the player when it hits the SSSD object
add force to up
name the sssd bounser
Ok cool.
So what we need to do is change a few things.
First of all your bouncer object is not going to collide with your player because it's too low. So what we can do is adjust the collider to be above the bouncer.
So on the bouncer adjust the "center" so the middle (second value) is 1. That should show you the collider is above the ground.
Then we do not actually want the collider to collide with the player (strange I know), but we want a trigger. This will allow the player to go through the object.
can u wait a few secounds to read it
The messages won't disappear ๐ take all the time you need.
what is the center
Y or Z or X
Y
?
No, so if you scroll down to the collider there are some options.
On your Box Collider component there is a Center option
Ok cool. So now we have to go to your code.
why we set the center to 1
That offsets the collider by +1 on the Y axis in the world. (That means it's now above your cube object)
to make the player dond collid with it
Yes, it raises it above the ground.
ok
For your code, we need to adjust the method from OnCollisionEnter to the following:
private void OnTriggerEnter(Collider other)
{
// Copy your if statement here
}
So earlier you showed your player script had a method in it, we need to adjust that
Yes, you can copy the if you were using.
Haha. That's fine we can go through it.
We'll do it slightly differently to how you originally did it, as we would rather use tags (or layers).
if(other.gameObject.CompareTag("bouncer"))
{
RB.AddForce(0, myBounceForce, 0);
}
Then, you can add a tag to your SSSD object.
why game object here
why its not collider
Because our trigger uses a different object
OnCollisionEnter uses a Collision object
OnTriggerEnter uses a collider
Excellent. Now if you play the game it should work.
Any issues with it just post them here.
should i change any thing here
Nope
see
Ok so first of all let's make sure that the trigger event is firing.
Let's add Debug.Log("trigger") to our OnTriggerEnter method.
Then let's run it again.
Do not put it inside the if statement
what is the sicrept to add on it debug.log
PlayerCollision
Ok, if you go to SSSD to the Box Collider there should be an edit collider button
Just make sure that's above ground.
Ok yes.
Then we'll go to our player object and make sure that our PlayerCollision component is correct
Can I see Player Collision as well
Ok, something isn't right here
You may need to restart unity.
Your code isn't reflective of what is on Unity.
Your Bouns Force should be My Bounce Force
You need to set the Rigidbody inside your PlayerCollision component.
It's showing as empty
No problem.