#Player doesnt teleport

1 messages · Page 1 of 1 (latest)

loud breach
wet axle
#

#faq_unity message

loud breach
#

i have a rigidbody on my player, but it doesnt work

#

can you explain it in a more noob terms?

#

im having a bit of trouble understanding

wet axle
#

The collisions and trigger methods will only be called
On objects that are in a Collision or trigger of course and have a rigidbody on them

#

You need only one rigidbody for Collision
But for receiving the call back in an objects you would need a rigidbody on that object

loud breach
#

so i need to have a rb on my player?

wet axle
#

So as you said you have a rigibody on the player if you try the same thing in a script on the player
It will work as the OnTriggerEnter will actually be called

wet axle
wet axle
#

The OnTriggerEnter isn't even being called
As it doesn't have a Rigibody on it

loud breach
#

it is being called, cause it says the debug.log

#

ima try putting the rb on it

wet axle
#

Oh is your player's rigidbody a kinematic one?

#

If not then use MovePosition or set it as kinematic before moving it around.

loud breach
#

i messed up and turns out i dont have a rigidbody on my player, but every other trigger worked exept for this, so i tought i did

wet axle
loud breach
#

so i need to have a rb on both objects or just one?

#

this trigger should teleport my player to the same pos in all axis, exept for z axis, which would need to be + 15

wet axle
#

Or have 2 rigidbodies

loud breach
#

will rb mess with the character controller?

#

i tried both having a rigidbody, it doesnt work

wet axle
#

As you are checking for just triggers shouldn't matter

loud breach
#

everything seemed fine when i put it on

wet axle
#

As kinematic rigidbodies pass through colliders

loud breach
#

nothing works

#

tried kinematic on both, on 1, on the other one

unborn kilnBOT
#

"It's not working" is not helpful

In order for a question to be answered, it must specify what exactly is wrong. Stating simply that "it doesn't work" is not sufficient.
Source: https://idownvotedbecau.se/itsnotworking

Please elaborate on your question by including all relevant details. What do you think is the problem? Have you tried to fix it? If you have, why didn't that work?

loud breach
#

if i have rb on trigger, it spams the debug.log

wet axle
#

Also you do realise that your code will teleport the player every time it enters the trigger
You don't have any checks for knowing if it's the correct object or not.

wet axle
loud breach
#

nothing

#

just debug.log

wet axle
#

Ok and what components do you have on the player?

#

Any errors?

loud breach
#

i previously had it check if the object entering the trigger was tagged by "player", but that didnt do anything either

#

no errors

#

only a spam of debug.log

#

literally every other trigger works, for example, i enter a trigger and i make an enemy move from one side to another, that works perfectly

#

item pick up triggers work perfectly too

#

but this just doesnt

wet axle
# loud breach

So this is the player and could you also send the other obj

loud breach
#

this is the trigger

wet axle
#

Any layer overrides?

wet axle
# loud breach

As this is the object set as trigger
Try adding a rigidbody to this instead

loud breach
#

i have not used any layers

loud breach
wet axle
# loud breach

Well the player isn't set as kinematic so it wouldn't move as expected

loud breach
#

just added the rb to trigger and set player rb to kinematic and nothing

#

just debug.log

#

ill give movePosition a try

#

is there any other way of doing this without movePosition?

#

that actually works

wet axle
loud breach
#

it teleports a cube, but not the player

wet axle
#

Look into it.

dawn bridge
dawn bridge
# loud breach

Using a CharacterController and a Rigidbody in tandem will not work. You need to decide on one or the other.

Also, character controllers will override their object's position. If you want to move the object by other means than the CC, you need to disable it, move the object, and re-enable it.

dawn bridge
# loud breach

Oops, meant to reply to this screenshot in my above message.

loud breach
#

oh shit, thanks, ill try to do that, when im back on the project

keen rose
#

The error is from your code

#

What you wrote is player.transform = player.transform

#

You will need to create a new Transform variable for the destination of the player

dawn bridge
#

Where'd you take that from?
OP has shared 1 piece of code. Nowhere in that code do they ever re-assign the player's transform (not to mention that this wouldn't even be possible).
But even if you mean that they wrote player.transform.position = player.transform.position, you would be wrong. OP did add 15f to the player's z position. Therefor, there would be an effect from just the code itself.

#

Although player.position += Vector3.forward * 15f; may have been a prettier way of writing it. LUL

keen rose
#

Yes you are right i'm very sorry

#

I did not see it 😅

#

It was only seeing player eveeywhere till i was no more paying attention on the rest

loud breach
#

vector3.forward changes the z axis only?

dawn bridge
#

Yes.
Vector3.right is always 1 0 0
Vector3.up is always 0 1 0
Vector3.forward is always 0 0 1

The same with -1 instead of 1 for .left, .down and .back.

loud breach
#

does transform have that too?

#

cause i used in one script transform.forward, but tried using also transform.right and it didnt work

#

only transform forward worked

dawn bridge
#

Transform as forward, right and up. Those behave different from the Vector3 ones, as the former always point in directions *relative to the Transform's rotation.

#

So if you have a rotation of 90 0 0 and use transform.forward, you'd get a vector facing down.

loud breach
#

how would i go about making a character controller be disabled and enabled the milisecond im teleported

#

and also will it affect the moving?

#

like for example, im moving and i disable it, enable it back and if im still holding W, the entire time, will i still move?

dawn bridge
dawn bridge
loud breach
#

alright, ill try and see if its good

#

or else ima need a new movement script

#

ohh damn its perfect

#

thank you so much