Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Tomblade13 · Oct 25, 2011 at 07:56 PM · topdownwallswasd

my character is moving through walls

My character is moving through walls with the new script I am using to move in world axis. I was wondering if someone could help me so that it dosent go through walls.

 var fixedDirection:Transform; //drag 'n drop the "Direction" game object to this slot.
 var speed:float = 1.0; //Change to whatever you want.
 
 function Update(){
  transform.Translate(fixedDirection.forward * Input.GetAxis("Vertical") * Time.deltaTime * speed);
  transform.Translate(fixedDirection.right * Input.GetAxis("Horizontal") * Time.deltaTime * speed);
 }

i dont understand why it is doing it.

any help would be appritiated.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Graham-Dunnett ♦♦ · Oct 25, 2011 at 08:04 PM 0
Share

where-abouts are you detecting collisions with the walls?

avatar image Tomblade13 · Oct 25, 2011 at 08:17 PM 0
Share

on the walls and on the character.

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Umbra · Oct 25, 2011 at 08:25 PM

When you simply adjust the transform like that, it doesn't care about collision control. Here's how I would do it:

 var controller:CharacterController = GetComponent(CharacterController)
 var MoveDirection:Vector3 = Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical");
 MoveDirection = transform.TransformDirection(MoveDirection);
 MoveDirection *= speed;

 controller.Move(MoveDirection * Time.deltaTime);

The Character Controller must be attached to your character (Component->Physics->CharacterController). For a better version of this script, look up the documentation for CharacterController.Move().

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tomblade13 · Oct 25, 2011 at 09:02 PM 0
Share

thx this worked perfectly

avatar image
0

Answer by easy_da_man · Oct 25, 2011 at 08:25 PM

Not sure if you have already done that!? But try attaching a RigidBody and a Collider to the game object in question. And you might check the objects your "controllable" game object collides with. They need at least RigidBody attached... maybe also a Collider. Read that up in the unity3d api reference: http://unity3d.com/support/documentation/Components/class-Rigidbody.html

You will find the entry for the Collider yourself :-)

Peace and good luck

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tomblade13 · Oct 25, 2011 at 08:45 PM 0
Share

for some reason as soon as i add a rigid body my character falls though the floor. this is very odd.

avatar image
0

Answer by PaxNemesis · Oct 25, 2011 at 08:18 PM

Check out CharacterController.SimpleMove should be what you need. :=)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tomblade13 · Oct 25, 2011 at 08:44 PM 0
Share

unfortunatly this is differnt from what i need as i need it to not rotate the camera when turning, i just need it to move the object in the direction of the movement key being pressed. thanks anyway.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Trying to Make a Topdown, 3rd Person Ladder 0 Answers

Vertical & horizontal movement world axis (top view) 1 Answer

Sprite facing object to mouse 0 Answers

What is the best way to achieve the transparant walls for ALL walls on screen that are not facing the player? 1 Answer

How can i make the ray cast don't go through the walls 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges