• 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 Aleks · Dec 01, 2010 at 02:49 PM · cameramovementmouse

Runescape Movement and camera rotation

The Player moves on clicked location by mouse

and Camera to rotate around the player when Left Right Up Down buttons pressed (just like runescape)

This may be difficult, but im sure a lot of people would like this idea

thanks ++

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
1
Best Answer

Answer by The_r0nin · Dec 01, 2010 at 04:23 PM

Try the Unity Script Wiki:

Click to Move

Keyboard Orbit

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
avatar image
1
Best Answer

Answer by Scribe · Dec 03, 2010 at 07:58 PM

var object : Transform;

function Update () {

if (Input.GetKey(KeyCode.DownArrow)) transform.RotateAround (object.position, Vector3(-1, 0, 0), 20 * Time.deltaTime);

if (Input.GetKey(KeyCode.UpArrow)) transform.RotateAround (object.position, Vector3(1, 0, 0), 20 * Time.deltaTime);

if (Input.GetKey(KeyCode.RightArrow)) transform.RotateAround (object.position, -Vector3.up, 20 * Time.deltaTime);

if (Input.GetKey(KeyCode.LeftArrow)) transform.RotateAround (object.position, Vector3.up, 20 * Time.deltaTime);

}

this is an updated script: set the object that you want to rotate around as the player in the inspector after adding the script to the camera, this will rotate around your players position.

Comment
Add comment · Show 3 · 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 Scribe · Dec 01, 2010 at 07:07 PM 1
Share

function Update () {

if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.DownArrow)) transform.Rotate(1, 0, 0);

if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.UpArrow)) transform.Rotate(-1, 0, 0);

if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.RightArrow)) transform.Rotate(0, 1, 0);

if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.LeftArrow)) transform.Rotate(0, -1, 0);

}

this can be used to rotate the camera just add this script to the main camera unfortuantly although The_r0nin link to click to move will work it will not find a path round obstacles so it will not walk round a building and through the door, it will either walk through the wall (no collider) or keep walking into the wall. the best way to do this is by downloading a pathfinding project like Aron Granberg's pathfinder here

incase the hyperlink didn't work (it sometimes doesn't :P)

http://www.arongranberg.com/unity/a-pathfinding/

avatar image Aleks Scribe · Dec 02, 2010 at 02:08 AM 0
Share

thanks for the answer Scribe but i need a script that the camera rotates like that but around the player. thanks anyway man

avatar image Scribe Scribe · Dec 03, 2010 at 08:00 PM 0
Share

your welcome. I've added a new script below which should rotate around the characters position. hope it helps

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

Top down movement and rotation 2 Answers

Erratic movement problem 2 Answers

Mouse Follow Script Help 1 Answer

How can I produce the typical FPS mouse steering effect? 2 Answers

Camera Movement issue 1 Answer

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