• Unity
  • Services
  • Made with Unity
  • Learn
  • 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
  • Forums
  • Answers
  • Feedback
  • Issue Tracker
  • Blog
  • Evangelists
  • User Groups

Navigation

  • Home
  • Unity
  • Industries
  • Made with Unity
  • Learn
  • Community
    • Forums
    • Answers
    • Feedback
    • Issue Tracker
    • Blog
    • Evangelists
    • User Groups
  • Get Unity
  • Asset Store

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
1
Question by Micha Lewtak · Jan 24, 2010 at 11:44 AM · physicsmovement

Finding an alternative for CharacterController.Move()

So I'm making a game with my own simplified physics because I need full control and knowledge of what's happening in each frame, but the one thing I still need to "ask" Unity to do for me is applying the actual movement which I calculated, in each fixed frame. I use the CharacterController component, only because it has the CharacterController.Move() function which I can move something with, slide it along walls if a collision happens, and also get the collision's normal. The problem's that I don't like this component. It has "weird" slope offset and step limit variables which are trash to me since I'm the one that'll be doing such checks IF I want to. Basically, I need a function similar to CharacterController.Move(), which only asks for a radius of a hypothetic sphere collider it will use to calculate the final position, having considered the slide it would do if it hit a surface during the movement. And which returns the collision normal (for now let's ignore multiple collisions).

Comment
Add comment
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

2 Replies

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

Answer by Ashkan_gc · Jan 24, 2010 at 12:04 PM

you should move your GameObject with transform.Translate and trace rays and check for collisions your self before moving the GameObject. you can check for sphere collisions and lineCast and raycast with methods of Physics class. also you can use triggers for collision detection. add a collider to your object and check it's "is trigger" box. then you can use OnTriggerEnter, OnTriggerExit and OnTriggerStay functions to get information about collisions without raycasting.

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 Micha Lewtak · Jan 24, 2010 at 02:19 PM 0
Share

Thank you for your answer, that's a good idea there. I guess "sliding" is just another complementary problem, as initially I'll just make the object stop completely if it's trying to run into a wall. Marking this as best answer because it has the most information and methods.

avatar image
1

Answer by StephanK · Jan 24, 2010 at 12:04 PM

Wouldn't it be easier to use the CharacterController and just set those variables to values that make them irrelevant?

If you really want to do your own physics (reinventing the wheel) and just need information about collisions I'd try to either use a sphere collider/trigger around the character, that has the radius of your characters speed. Or just do some raycasts in the direction of speed and see if you are hitting something before moving. RaycastHit will also tell you about the exact point and the normal of the surface you hit.

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 Micha Lewtak · Jan 24, 2010 at 02:18 PM 0
Share

Thank you for your answer, that's a good idea there.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Object attached to player doesn't collide 0 Answers

Character Controller 0 Answers

Physics: Auto-stopping a spaceship with reverse thrusters 1 Answer

Is mixing movement types a bad thing to do? (Force and Translate) 1 Answer

How to check if object is on ground (C#)? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges