• 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 Jonathan Genesis · Apr 10, 2013 at 03:39 AM · rotationgravityramp

Scripting, Rotate and set gravity on collision

I am making a game where there is a ramp and as the player moves on the ramp the rotation and the gravity of all the objects in the scene change to that angle and as the player moves up the ramp the angle changes until it reaches 90 degrees PLEASE HELP looked everywhere cant find anything. here are before and after pics of what it should look like.

alt text

alt text

it is not scripted just placed the objects. i have some knowledge of code but this is a tad to advanced for me please help it will be greatly appreciated.

screen shot 2013-04-09 at 6.12.52 pm.png (172.5 kB)
screen shot 2013-04-09 at 6.11.11 pm.png (260.1 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by OllyNicholson · Apr 15, 2013 at 11:19 AM

Hi - you may still need assistance with the scripting (perhaps see collaboration section on the forums?) but essentially you should be able to update the orientation of your player at each frame by raycasting down at the surface your player is on and comparing the surface normal with the world orientation to perform a calculation and accordingly update the player orientation at every frame. This would allow for your objects to behave correctly with the new gravity orientation as your player moves up the ramp.

http://docs.unity3d.com/Documentation/ScriptReference/RaycastHit-normal.html

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

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

11 People are following this question.

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

Related Questions

Applying force with respect to angle with the ground? 1 Answer

Rotational Gravity - Camera and Force problems 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Faux Gravity Prolem? #2 2 Answers

Getting the rotation of an object does not return correct rotation 1 Answer

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