view follow an Actor Problem

Talk about making games.

view follow an Actor Problem

Postby Behdadsoft » Wed Jun 18, 2014 10:38 am

Hi.
I want follow view according to Player Move. I create a actor and add this code:

Draw Actor => Script Editor :

Code: Select all
int weight =5;
x = ((weight - 1)*x +Player.x)/weight;


but when play the game view move to left and make a black screen.i change weight value but no give good reason. how can fix it?

Thanks.
Attachments
pic2.jpg
There is no possible way, if we found will make a way.

http://behdadsoft.com/
*******************************************************************
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0
User avatar
Behdadsoft
 
Posts: 207
Joined: Wed Dec 16, 2009 9:19 pm
Score: 2 Give a positive score

Re: view follow an Actor Problem

Postby DeltaLeeds » Wed Jun 18, 2014 3:21 pm

Behdadsoft wrote:Hi.
I want follow view according to Player Move. I create a actor and add this code:

Draw Actor => Script Editor :

Code: Select all
int weight =5;
x = ((weight - 1)*x +Player.x)/weight;


but when play the game view move to left and make a black screen.i change weight value but no give good reason. how can fix it?

Thanks.

Hello Behdad! You don't need to use draw actor and stuff, you can just make view's parent the player actor and it will follow the player automatically. :)
Currently: Semi-Active.
Working on: Maybe putting my test games in gamejolt, polishing them a bit, but I still don't know when.
User avatar
DeltaLeeds
 
Posts: 693
Joined: Fri May 06, 2011 12:45 pm
Location: In front of my computer.
Score: 38 Give a positive score

Re: view follow an Actor Problem

Postby Behdadsoft » Thu Jun 19, 2014 12:18 pm

Thanks jonathang is good idea but still show a little Black screen when Player Move back to Left.
There is no possible way, if we found will make a way.

http://behdadsoft.com/
*******************************************************************
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0
User avatar
Behdadsoft
 
Posts: 207
Joined: Wed Dec 16, 2009 9:19 pm
Score: 2 Give a positive score

Re: view follow an Actor Problem

Postby Goettsch » Thu Jun 19, 2014 12:26 pm

Behdadsoft wrote:Thanks jonathang is good idea but still show a little Black screen when Player Move back to Left.

You can put other tiles in the black space
Support me and open these links:
http://adf.ly/pZps0 (as many times as you can)
http://VisitsToMoney.com/index.php?refId=470333 (open once)
http://Visitors2Cash.com/ref.php?refId=169224 (open once)
My games:
Kingdoms of... http://adf.ly/pZq5O
Goettsch
 
Posts: 124
Joined: Fri Jun 28, 2013 10:00 pm
Score: 5 Give a positive score

Re: view follow an Actor Problem

Postby Behdadsoft » Fri Jun 20, 2014 7:01 pm

You can put other tiles in the black space


this is not good idea because when I climp up ladder the view move to up and make half black screen.I can't put any thing in sky.
Attachments
pic2.jpg
There is no possible way, if we found will make a way.

http://behdadsoft.com/
*******************************************************************
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0
User avatar
Behdadsoft
 
Posts: 207
Joined: Wed Dec 16, 2009 9:19 pm
Score: 2 Give a positive score

Re: view follow an Actor Problem

Postby Goettsch » Sat Jun 21, 2014 10:27 am

Then, create two wire frame regions, make them as tall as the view, and put one of them at player.x-=30 and the other at player.x+=30
Then use this code:
Player-> collision -> right side of the first wire frame region,repeat: yes
View.x-=(the speed of the player)

Then add this code to :player-> collision -> left side of the second wire frame region, repeat: yes
View.x+=(the speed of the player)

then set the two wire frame regions to be parents of the view
Support me and open these links:
http://adf.ly/pZps0 (as many times as you can)
http://VisitsToMoney.com/index.php?refId=470333 (open once)
http://Visitors2Cash.com/ref.php?refId=169224 (open once)
My games:
Kingdoms of... http://adf.ly/pZq5O
Goettsch
 
Posts: 124
Joined: Fri Jun 28, 2013 10:00 pm
Score: 5 Give a positive score

Re: view follow an Actor Problem

Postby Zivouhr » Fri Jul 25, 2014 4:32 am

Sounds like good advice.

I usually have the view have the player as the parent to simplify things, but there is a demo created on this forum, where the stick figure they created moves left or right and the screen scrolls left or right once they hit one of those side regions parented to the view I think. That allows for some slack in the player's left right movement, but if I remember, the demo will give some ideas about not having the view parented to the player, but still follows the player.

Otherwise, you could possibly just assign the same X speed that the player has for his x movement (left or right), without parenting the view. Here's another suggestion; simple way;

View/keydown/left/repeat On/Script editor:
x-=6; // - makes the view go left here. // = notes, not actual code, to inform those new to coding.

View/keydown/right/repeat On/Script editor:
x+=6; //+ makes view go right.

--------

player/keydown/left/repeat On/Script editor:
x-=6; // - makes the player go left here. // = notes, not actual code, to inform those new to coding.

player/keydown/right/repeat On/Script editor:
x+=6; //+ makes player go right.


--------

That will allow the player to move freely left or right, and the camera VIEW will follow those movements, but only if the player is not stopped by a wall. In that case, if you keep pressing right, and the player is stopped, using this coding, then the view will keep moving independent of the player, eventually leaving the player offscreen which wouldn't be the goal.

In that case, you'd definitely want Goettsch's idea, that sounds like it will work, though I haven't tested this out yet.

Just trying to offer some ideas, as I'm learning myself, having completed only my first game.
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest