- Home /
Colliders and GetKey
Hi everybody
I have an object controlled by player (controls with arrow keys, script already done, p.o. moves on the x/z axis for 0.5. With a counter I managed to make it move while button is down, but only 5 times per step, so it's as fast as I wish it to be) That "player object" is moved around in a closed room (plane, 4 walls) In that room there are several cubes.
What I want to do 1:
Moving the player object around in the room. It should be stopped by the walls. Walls and p.o. have box colliders, p.o. has a rigidbody with gravitation and stop rotation enabled.
Problem 1: When p.o. hits a wall, it doesn't just stop moving, it's pushed backwards by the wall and it moves backwards slowly.
Question: How can I make the p.o. just being stopped by the wall without any other movement? (wall as an obstacle)
What I want to do 2:
When p.o. collides with a cube in the room, it should be stopped (same as in point 1) BUT: When it is stopped by the cube, and player pushes the space key, the cube should be pushed in the opposite direction from the player object, and it sould move until it is stopped by a wall or another cube. But it can't be stopped by the player.
(for those of you who played zelda: twilight princess, my idea is to create a game that's like the part in the ice-land where you push arund ice-cubes until one of them stays on a certain position (= key on the ground) which opens a door or triggers another action)
problem 2:
The pushing is only possible when the p.o. is touching the cube. So I guess I need an enter collision function and then write if(Input.GetKey("space") --> transform position blahblah...but I don't now how exactly...
I'm new at scripting and I want to keep it as easy as possible... ;)
Greez
L.