<blockquote class="Quote">
<a target="blank" rel="nofollow">Ross</a> said:
So the zooming works but doesn't happen when you think it should?<br><br>Put a print statement in your area_body_enter function and watch the log to see when it happens. Are you changing the collision shape with code at all? <br><br>We might be able to help more if you post the code you're using. <br>
</blockquote>
Here is the code: <br>
extends Node2D<br><br># member variables here, example:<br># var a=2<br># var b="textvar"<br>var area = null<br>var inside = false<br>var out = 1<br>var back<br>var state<br>var hero = null<br>func _ready():<br> area = get_node("Area2D")<br> back = get_node("/root/Mundo/Course/hero/physics/Camera").get_zoom()<br> state = back<br> hero = get_node("/root/Mundo/Course/hero")<br> set_fixed_process(true)<br>func _fixed_process(delta):<br># if inside == true:<br># zoom_out()<br># else:<br># zoom_in()<br><br> if area.overlaps_body(get_node("/root/Mundo/Course/hero/physics")):<br> if inside == false:<br> hero.inside = hero.inside+1<br> inside = true<br> if hero.inside!=0:<br> state = hero.get_node("physics/Camera").get_zoom()<br> zoom_out()<br> elif !area.overlaps_body(get_node("/root/Mundo/Course/hero/physics")):<br> if inside == true:<br> hero.inside = hero.inside-1<br> inside = false<br># zoom_in()<br> if hero.inside==0:<br> state=hero.get_node("physics/Camera").get_zoom()<br> zoom_in()<br># print(hero.inside)<br>func zoom_out():<br> if state.x < out:<br> state=state+Vector2(0.005/hero.inside,0.005/hero.inside)<br> get_node("/root/Mundo/Course/hero/physics/Camera").set_zoom(state)<br> else:<br> pass<br>func zoom_in():<br> if state > back:<br> state=state-Vector2(0.005,0.005)<br> get_node("/root/Mundo/Course/hero/physics/Camera").set_zoom(state)<br> else:<br> get_node("/root/Mundo/Course/hero/physics/Camera").set_zoom(back)<br> pass<br><br>
<p>The structure of the nodes is "Node 2d--->Area2D--->collisionshape2d". I did what you said (monitor the entering) and it happens in the "in game 2" figure :/. Just to clarify a bit: "/root/Mundo/Course/hero/physics" is a RigidBody2D.</p><p>I fell I have to apologise for my messy code.<br></p>